Fossil SCM

Enhance "fossil diff --numstat" to print a grand total line, and not display statistics for non-modified files.

danield 2020-12-18 15:30 trunk
Commit f8a5a6a7167a0935fc6d9e9e30173cf881b66e29815402440560fe6b4c7d5a13
+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
@@ -855,10 +855,11 @@
855855
const char *zBinGlob = 0; /* Treat file names matching this as binary */
856856
int fIncludeBinary = 0; /* Include binary files for external diff */
857857
int againstUndo = 0; /* Diff against files in the undo buffer */
858858
u64 diffFlags = 0; /* Flags to control the DIFF */
859859
FileDirList *pFileDir = 0; /* Restrict the diff to these files */
860
+ g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
860861
861862
if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
862863
diff_tk("diff", 2);
863864
return;
864865
}
@@ -958,10 +959,13 @@
958959
}
959960
fossil_free(pFileDir[i].zName);
960961
}
961962
fossil_free(pFileDir);
962963
}
964
+ if ( diffFlags & DIFF_NUMSTAT )
965
+ fossil_print("%d files changed, %d insertions, %d deletions\n",
966
+ g.diffCnt[0], g.diffCnt[1], g.diffCnt[2]);
963967
}
964968
965969
/*
966970
** WEBPAGE: vpatch
967971
** URL: /vpatch?from=FROM&to=TO
968972
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -855,10 +855,11 @@
855 const char *zBinGlob = 0; /* Treat file names matching this as binary */
856 int fIncludeBinary = 0; /* Include binary files for external diff */
857 int againstUndo = 0; /* Diff against files in the undo buffer */
858 u64 diffFlags = 0; /* Flags to control the DIFF */
859 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
 
860
861 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
862 diff_tk("diff", 2);
863 return;
864 }
@@ -958,10 +959,13 @@
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
@@ -855,10 +855,11 @@
855 const char *zBinGlob = 0; /* Treat file names matching this as binary */
856 int fIncludeBinary = 0; /* Include binary files for external diff */
857 int againstUndo = 0; /* Diff against files in the undo buffer */
858 u64 diffFlags = 0; /* Flags to control the DIFF */
859 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
860 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
861
862 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
863 diff_tk("diff", 2);
864 return;
865 }
@@ -958,10 +959,13 @@
959 }
960 fossil_free(pFileDir[i].zName);
961 }
962 fossil_free(pFileDir);
963 }
964 if ( diffFlags & DIFF_NUMSTAT )
965 fossil_print("%d files changed, %d insertions, %d deletions\n",
966 g.diffCnt[0], g.diffCnt[1], g.diffCnt[2]);
967 }
968
969 /*
970 ** WEBPAGE: vpatch
971 ** URL: /vpatch?from=FROM&to=TO
972
+1
--- src/main.c
+++ src/main.c
@@ -320,10 +320,11 @@
320320
} reqPayload; /* request payload object (if any) */
321321
cson_array *warnings; /* response warnings */
322322
int timerId; /* fetched from fossil_timer_start() */
323323
} json;
324324
#endif /* FOSSIL_ENABLE_JSON */
325
+ int diffCnt[3]; /* Counts for DIFF_NUMSTAT: files, ins, del */
325326
};
326327
327328
/*
328329
** Macro for debugging:
329330
*/
330331
--- src/main.c
+++ src/main.c
@@ -320,10 +320,11 @@
320 } reqPayload; /* request payload object (if any) */
321 cson_array *warnings; /* response warnings */
322 int timerId; /* fetched from fossil_timer_start() */
323 } json;
324 #endif /* FOSSIL_ENABLE_JSON */
 
325 };
326
327 /*
328 ** Macro for debugging:
329 */
330
--- src/main.c
+++ src/main.c
@@ -320,10 +320,11 @@
320 } reqPayload; /* request payload object (if any) */
321 cson_array *warnings; /* response warnings */
322 int timerId; /* fetched from fossil_timer_start() */
323 } json;
324 #endif /* FOSSIL_ENABLE_JSON */
325 int diffCnt[3]; /* Counts for DIFF_NUMSTAT: files, ins, del */
326 };
327
328 /*
329 ** Macro for debugging:
330 */
331

Keyboard Shortcuts

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