Hi,
A patch (against trunk, 14d8d31b1a) that adds the option '--numstat' to
'fossil diff' for functionality similar to 'git diff --numstat': for
each file in the diff a line is output with three elements: number of
added lines, number of removed lines, and the file path, separated with
tabs.
Best regards,
Daniel
Am 19.06.2017 um 23:19 schrieb Ross Berteig:
> On 6/18/2017 7:22 PM, The Tick wrote:
>> Just wondering if this exists or if it would have to be scripted -- a
>> way to get a per-file recap of added/changed/removed lines for the
>> files in a commit. It would be a way to quickly gauge the amount of
>> changes that had occurred.
>
> Of course there's the simple list provided by "fossil changes", but that
> only shows file names which changed.
>
> There's aksi "fossil diff --brief", which also only shows file names
> with changes. Without the --brief option, it shows the entire change,
> which is more than you wanted. But it does support the --checkin option
> which shows what changed in that particular checkin.
>
> If you configure fossil to use an external diff utility, you might be
> able to find one that has a summary mode that is more verbose than
> --brief and less complete than the usual output. The somewhat elderly
> GNU diff I have here on my Windows box (version 2.8.7 built in 2004
> apparently) does not have such an option. Read about "fossil set
> diff-command" for how to do that.
>
Index: src/diff.c
==
--- src/diff.c
+++ src/diff.c
@@ -39,2 +39,3 @@
#define DIFF_LINENO ((u64)0x4000) /* Show line numbers */
+#define DIFF_NUMSTAT ((u64)0x8000) /* Show statistics */
#define DIFF_NOOPT(((u64)0x01)<<32) /* Suppress optimizations (debug)
*/
@@ -1958,2 +1959,3 @@
** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
+** --numstat Display statistics DIFF_NUMSTAT
*/
@@ -1988,2 +1990,3 @@
if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
+ if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT;
if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
Index: src/diffcmd.c
==
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -111,3 +111,3 @@
void diff_print_index(const char *zFile, u64 diffFlags){
- if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){
+ if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF|DIFF_NUMSTAT))==0 ){
char *z = mprintf("Index: %s\n%.66c\n", zFile, '=');
@@ -200,2 +200,18 @@
}
+ }
+ else if( diffFlags & DIFF_NUMSTAT ){
+ int *R;
+ int r;
+ int linesDeleted = 0;
+ int linesAdded = 0;
+ if( fSwapDiff ) {
+ R = text_diff(, pFile1, 0, 0, diffFlags);
+ }else{
+ R = text_diff(pFile1, , 0, 0, diffFlags);
+ }
+ for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){
+ linesDeleted += R[r+1];
+ linesAdded += R[r+2];
+ }
+ fossil_print("%d\t%d\t%s\n", linesAdded, linesDeleted, zName);
}else{
@@ -309,2 +325,15 @@
if( diffFlags & DIFF_BRIEF ) return;
+ if( diffFlags & DIFF_NUMSTAT ){
+ int *R;
+ int r;
+ int linesDeleted = 0;
+ int linesAdded = 0;
+ R = text_diff(pFile1, pFile2, 0, 0, diffFlags);
+ for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){
+ linesDeleted += R[r+1];
+ linesAdded += R[r+2];
+ }
+ fossil_print("%d\t%d\t%s\n", linesAdded, linesDeleted, zName);
+ return;
+ }
if( zDiffCmd==0 ){
@@ -860,2 +889,3 @@
int againstUndo = 0; /* Diff against files in the undo buffer */
+ int numStat = 0; /* Print diff statistics */
u64 diffFlags = 0; /* Flags to control the DIFF */
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users