Fossil SCM

The --numstat option to "fossil diff" now shows a total at the end.

drh 2021-01-07 16:21 trunk merge
Commit 9bb61a420bf5158bcfecc38c891bb649d12c51dc4638843b07810eb732945555
+6 -1
--- src/diff.c
+++ src/diff.c
@@ -1955,11 +1955,16 @@
19551955
int nDel = 0, nIns = 0, i;
19561956
for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
19571957
nDel += c.aEdit[i+1];
19581958
nIns += c.aEdit[i+2];
19591959
}
1960
- blob_appendf(pOut, "%10d %10d", nIns, nDel);
1960
+ g.diffCnt[1] += nIns;
1961
+ g.diffCnt[2] += nDel;
1962
+ if( nIns+nDel ){
1963
+ g.diffCnt[0]++;
1964
+ blob_appendf(pOut, "%10d %10d", nIns, nDel);
1965
+ }
19611966
}else if( diffFlags & DIFF_SIDEBYSIDE ){
19621967
sbsDiff(&c, pOut, pRe, diffFlags);
19631968
}else{
19641969
contextDiff(&c, pOut, pRe, diffFlags);
19651970
}
19661971
--- src/diff.c
+++ src/diff.c
@@ -1955,11 +1955,16 @@
1955 int nDel = 0, nIns = 0, i;
1956 for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
1957 nDel += c.aEdit[i+1];
1958 nIns += c.aEdit[i+2];
1959 }
1960 blob_appendf(pOut, "%10d %10d", nIns, nDel);
 
 
 
 
 
1961 }else if( diffFlags & DIFF_SIDEBYSIDE ){
1962 sbsDiff(&c, pOut, pRe, diffFlags);
1963 }else{
1964 contextDiff(&c, pOut, pRe, diffFlags);
1965 }
1966
--- src/diff.c
+++ src/diff.c
@@ -1955,11 +1955,16 @@
1955 int nDel = 0, nIns = 0, i;
1956 for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
1957 nDel += c.aEdit[i+1];
1958 nIns += c.aEdit[i+2];
1959 }
1960 g.diffCnt[1] += nIns;
1961 g.diffCnt[2] += nDel;
1962 if( nIns+nDel ){
1963 g.diffCnt[0]++;
1964 blob_appendf(pOut, "%10d %10d", nIns, nDel);
1965 }
1966 }else if( diffFlags & DIFF_SIDEBYSIDE ){
1967 sbsDiff(&c, pOut, pRe, diffFlags);
1968 }else{
1969 contextDiff(&c, pOut, pRe, diffFlags);
1970 }
1971
+6 -1
--- src/diff.c
+++ src/diff.c
@@ -1955,11 +1955,16 @@
19551955
int nDel = 0, nIns = 0, i;
19561956
for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
19571957
nDel += c.aEdit[i+1];
19581958
nIns += c.aEdit[i+2];
19591959
}
1960
- blob_appendf(pOut, "%10d %10d", nIns, nDel);
1960
+ g.diffCnt[1] += nIns;
1961
+ g.diffCnt[2] += nDel;
1962
+ if( nIns+nDel ){
1963
+ g.diffCnt[0]++;
1964
+ blob_appendf(pOut, "%10d %10d", nIns, nDel);
1965
+ }
19611966
}else if( diffFlags & DIFF_SIDEBYSIDE ){
19621967
sbsDiff(&c, pOut, pRe, diffFlags);
19631968
}else{
19641969
contextDiff(&c, pOut, pRe, diffFlags);
19651970
}
19661971
--- src/diff.c
+++ src/diff.c
@@ -1955,11 +1955,16 @@
1955 int nDel = 0, nIns = 0, i;
1956 for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
1957 nDel += c.aEdit[i+1];
1958 nIns += c.aEdit[i+2];
1959 }
1960 blob_appendf(pOut, "%10d %10d", nIns, nDel);
 
 
 
 
 
1961 }else if( diffFlags & DIFF_SIDEBYSIDE ){
1962 sbsDiff(&c, pOut, pRe, diffFlags);
1963 }else{
1964 contextDiff(&c, pOut, pRe, diffFlags);
1965 }
1966
--- src/diff.c
+++ src/diff.c
@@ -1955,11 +1955,16 @@
1955 int nDel = 0, nIns = 0, i;
1956 for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
1957 nDel += c.aEdit[i+1];
1958 nIns += c.aEdit[i+2];
1959 }
1960 g.diffCnt[1] += nIns;
1961 g.diffCnt[2] += nDel;
1962 if( nIns+nDel ){
1963 g.diffCnt[0]++;
1964 blob_appendf(pOut, "%10d %10d", nIns, nDel);
1965 }
1966 }else if( diffFlags & DIFF_SIDEBYSIDE ){
1967 sbsDiff(&c, pOut, pRe, diffFlags);
1968 }else{
1969 contextDiff(&c, pOut, pRe, diffFlags);
1970 }
1971
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -887,10 +887,11 @@
887887
zFrom = mprintf("root:%s", zBranch);
888888
}
889889
if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
890890
fossil_fatal("cannot use --checkin together with --from or --to");
891891
}
892
+ g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
892893
if( zTo==0 || againstUndo ){
893894
db_must_be_within_tree();
894895
}else if( zFrom==0 ){
895896
fossil_fatal("must use --from if --to is present");
896897
}else{
@@ -958,10 +959,14 @@
958959
}
959960
fossil_free(pFileDir[i].zName);
960961
}
961962
fossil_free(pFileDir);
962963
}
964
+ if ( diffFlags & DIFF_NUMSTAT ){
965
+ fossil_print("%10d %10d TOTAL over %d changed files\n",
966
+ g.diffCnt[1], g.diffCnt[2], g.diffCnt[0]);
967
+ }
963968
}
964969
965970
/*
966971
** WEBPAGE: vpatch
967972
** URL: /vpatch?from=FROM&to=TO
968973
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -887,10 +887,11 @@
887 zFrom = mprintf("root:%s", zBranch);
888 }
889 if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
890 fossil_fatal("cannot use --checkin together with --from or --to");
891 }
 
892 if( zTo==0 || againstUndo ){
893 db_must_be_within_tree();
894 }else if( zFrom==0 ){
895 fossil_fatal("must use --from if --to is present");
896 }else{
@@ -958,10 +959,14 @@
958 }
959 fossil_free(pFileDir[i].zName);
960 }
961 fossil_free(pFileDir);
962 }
 
 
 
 
963 }
964
965 /*
966 ** WEBPAGE: vpatch
967 ** URL: /vpatch?from=FROM&to=TO
968
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -887,10 +887,11 @@
887 zFrom = mprintf("root:%s", zBranch);
888 }
889 if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
890 fossil_fatal("cannot use --checkin together with --from or --to");
891 }
892 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
893 if( zTo==0 || againstUndo ){
894 db_must_be_within_tree();
895 }else if( zFrom==0 ){
896 fossil_fatal("must use --from if --to is present");
897 }else{
@@ -958,10 +959,14 @@
959 }
960 fossil_free(pFileDir[i].zName);
961 }
962 fossil_free(pFileDir);
963 }
964 if ( diffFlags & DIFF_NUMSTAT ){
965 fossil_print("%10d %10d TOTAL over %d changed files\n",
966 g.diffCnt[1], g.diffCnt[2], g.diffCnt[0]);
967 }
968 }
969
970 /*
971 ** WEBPAGE: vpatch
972 ** URL: /vpatch?from=FROM&to=TO
973
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -887,10 +887,11 @@
887887
zFrom = mprintf("root:%s", zBranch);
888888
}
889889
if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
890890
fossil_fatal("cannot use --checkin together with --from or --to");
891891
}
892
+ g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
892893
if( zTo==0 || againstUndo ){
893894
db_must_be_within_tree();
894895
}else if( zFrom==0 ){
895896
fossil_fatal("must use --from if --to is present");
896897
}else{
@@ -958,10 +959,14 @@
958959
}
959960
fossil_free(pFileDir[i].zName);
960961
}
961962
fossil_free(pFileDir);
962963
}
964
+ if ( diffFlags & DIFF_NUMSTAT ){
965
+ fossil_print("%10d %10d TOTAL over %d changed files\n",
966
+ g.diffCnt[1], g.diffCnt[2], g.diffCnt[0]);
967
+ }
963968
}
964969
965970
/*
966971
** WEBPAGE: vpatch
967972
** URL: /vpatch?from=FROM&to=TO
968973
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -887,10 +887,11 @@
887 zFrom = mprintf("root:%s", zBranch);
888 }
889 if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
890 fossil_fatal("cannot use --checkin together with --from or --to");
891 }
 
892 if( zTo==0 || againstUndo ){
893 db_must_be_within_tree();
894 }else if( zFrom==0 ){
895 fossil_fatal("must use --from if --to is present");
896 }else{
@@ -958,10 +959,14 @@
958 }
959 fossil_free(pFileDir[i].zName);
960 }
961 fossil_free(pFileDir);
962 }
 
 
 
 
963 }
964
965 /*
966 ** WEBPAGE: vpatch
967 ** URL: /vpatch?from=FROM&to=TO
968
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -887,10 +887,11 @@
887 zFrom = mprintf("root:%s", zBranch);
888 }
889 if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
890 fossil_fatal("cannot use --checkin together with --from or --to");
891 }
892 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
893 if( zTo==0 || againstUndo ){
894 db_must_be_within_tree();
895 }else if( zFrom==0 ){
896 fossil_fatal("must use --from if --to is present");
897 }else{
@@ -958,10 +959,14 @@
959 }
960 fossil_free(pFileDir[i].zName);
961 }
962 fossil_free(pFileDir);
963 }
964 if ( diffFlags & DIFF_NUMSTAT ){
965 fossil_print("%10d %10d TOTAL over %d changed files\n",
966 g.diffCnt[1], g.diffCnt[2], g.diffCnt[0]);
967 }
968 }
969
970 /*
971 ** WEBPAGE: vpatch
972 ** URL: /vpatch?from=FROM&to=TO
973
+1
--- src/main.c
+++ src/main.c
@@ -321,10 +321,11 @@
321321
} reqPayload; /* request payload object (if any) */
322322
cson_array *warnings; /* response warnings */
323323
int timerId; /* fetched from fossil_timer_start() */
324324
} json;
325325
#endif /* FOSSIL_ENABLE_JSON */
326
+ int diffCnt[3]; /* Counts for DIFF_NUMSTAT: files, ins, del */
326327
};
327328
328329
/*
329330
** Macro for debugging:
330331
*/
331332
--- src/main.c
+++ src/main.c
@@ -321,10 +321,11 @@
321 } reqPayload; /* request payload object (if any) */
322 cson_array *warnings; /* response warnings */
323 int timerId; /* fetched from fossil_timer_start() */
324 } json;
325 #endif /* FOSSIL_ENABLE_JSON */
 
326 };
327
328 /*
329 ** Macro for debugging:
330 */
331
--- src/main.c
+++ src/main.c
@@ -321,10 +321,11 @@
321 } reqPayload; /* request payload object (if any) */
322 cson_array *warnings; /* response warnings */
323 int timerId; /* fetched from fossil_timer_start() */
324 } json;
325 #endif /* FOSSIL_ENABLE_JSON */
326 int diffCnt[3]; /* Counts for DIFF_NUMSTAT: files, ins, del */
327 };
328
329 /*
330 ** Macro for debugging:
331 */
332
+1
--- src/main.c
+++ src/main.c
@@ -321,10 +321,11 @@
321321
} reqPayload; /* request payload object (if any) */
322322
cson_array *warnings; /* response warnings */
323323
int timerId; /* fetched from fossil_timer_start() */
324324
} json;
325325
#endif /* FOSSIL_ENABLE_JSON */
326
+ int diffCnt[3]; /* Counts for DIFF_NUMSTAT: files, ins, del */
326327
};
327328
328329
/*
329330
** Macro for debugging:
330331
*/
331332
--- src/main.c
+++ src/main.c
@@ -321,10 +321,11 @@
321 } reqPayload; /* request payload object (if any) */
322 cson_array *warnings; /* response warnings */
323 int timerId; /* fetched from fossil_timer_start() */
324 } json;
325 #endif /* FOSSIL_ENABLE_JSON */
 
326 };
327
328 /*
329 ** Macro for debugging:
330 */
331
--- src/main.c
+++ src/main.c
@@ -321,10 +321,11 @@
321 } reqPayload; /* request payload object (if any) */
322 cson_array *warnings; /* response warnings */
323 int timerId; /* fetched from fossil_timer_start() */
324 } json;
325 #endif /* FOSSIL_ENABLE_JSON */
326 int diffCnt[3]; /* Counts for DIFF_NUMSTAT: files, ins, del */
327 };
328
329 /*
330 ** Macro for debugging:
331 */
332

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button