Fossil SCM

Add the --numstat option to the diff command.

drh 2017-06-30 19:59 trunk
Commit 3d6cf6a7226c740936af790d02a62691a3fcd4d1d23c3c4a244a662062cb3e0c
2 files changed +11 -2 +30 -15
+11 -2
--- src/diff.c
+++ src/diff.c
@@ -35,10 +35,11 @@
3535
#define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */
3636
#define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */
3737
#define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */
3838
#define DIFF_HTML ((u64)0x20000000) /* Render for HTML */
3939
#define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */
40
+#define DIFF_NUMSTAT ((u64)0x80000000) /* Show line count of changes */
4041
#define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
4142
#define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
4243
#define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
4344
#define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
4445
#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
@@ -1918,12 +1919,18 @@
19181919
if( (diffFlags & DIFF_NOOPT)==0 ){
19191920
diff_optimize(&c);
19201921
}
19211922
19221923
if( pOut ){
1923
- /* Compute a context or side-by-side diff into pOut */
1924
- if( diffFlags & DIFF_SIDEBYSIDE ){
1924
+ if( diffFlags & DIFF_NUMSTAT ){
1925
+ int nDel = 0, nIns = 0, i;
1926
+ for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
1927
+ nDel += c.aEdit[i+1];
1928
+ nIns += c.aEdit[i+2];
1929
+ }
1930
+ blob_appendf(pOut, "%10d %10d", nIns, nDel);
1931
+ }else if( diffFlags & DIFF_SIDEBYSIDE ){
19251932
sbsDiff(&c, pOut, pRe, diffFlags);
19261933
}else{
19271934
contextDiff(&c, pOut, pRe, diffFlags);
19281935
}
19291936
fossil_free(c.aFrom);
@@ -1948,10 +1955,11 @@
19481955
** -c|--context N N lines of context. DIFF_CONTEXT_MASK
19491956
** --html Format for HTML DIFF_HTML
19501957
** --invert Invert the diff DIFF_INVERT
19511958
** -n|--linenum Show line numbers DIFF_LINENO
19521959
** --noopt Disable optimization DIFF_NOOPT
1960
+** --numstat Show change counts DIFF_NUMSTAT
19531961
** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
19541962
** --unified Unified diff. ~DIFF_SIDEBYSIDE
19551963
** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
19561964
** -W|--width N N character lines. DIFF_WIDTH_MASK
19571965
** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
@@ -1985,10 +1993,11 @@
19851993
diffFlags |= f;
19861994
}
19871995
if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
19881996
if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
19891997
if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
1998
+ if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT;
19901999
if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
19912000
if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
19922001
return diffFlags;
19932002
}
19942003
19952004
--- src/diff.c
+++ src/diff.c
@@ -35,10 +35,11 @@
35 #define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */
36 #define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */
37 #define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */
38 #define DIFF_HTML ((u64)0x20000000) /* Render for HTML */
39 #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */
 
40 #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
41 #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
42 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
43 #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
44 #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
@@ -1918,12 +1919,18 @@
1918 if( (diffFlags & DIFF_NOOPT)==0 ){
1919 diff_optimize(&c);
1920 }
1921
1922 if( pOut ){
1923 /* Compute a context or side-by-side diff into pOut */
1924 if( diffFlags & DIFF_SIDEBYSIDE ){
 
 
 
 
 
 
1925 sbsDiff(&c, pOut, pRe, diffFlags);
1926 }else{
1927 contextDiff(&c, pOut, pRe, diffFlags);
1928 }
1929 fossil_free(c.aFrom);
@@ -1948,10 +1955,11 @@
1948 ** -c|--context N N lines of context. DIFF_CONTEXT_MASK
1949 ** --html Format for HTML DIFF_HTML
1950 ** --invert Invert the diff DIFF_INVERT
1951 ** -n|--linenum Show line numbers DIFF_LINENO
1952 ** --noopt Disable optimization DIFF_NOOPT
 
1953 ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
1954 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
1955 ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
1956 ** -W|--width N N character lines. DIFF_WIDTH_MASK
1957 ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
@@ -1985,10 +1993,11 @@
1985 diffFlags |= f;
1986 }
1987 if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
1988 if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
1989 if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
 
1990 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
1991 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
1992 return diffFlags;
1993 }
1994
1995
--- src/diff.c
+++ src/diff.c
@@ -35,10 +35,11 @@
35 #define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */
36 #define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */
37 #define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */
38 #define DIFF_HTML ((u64)0x20000000) /* Render for HTML */
39 #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */
40 #define DIFF_NUMSTAT ((u64)0x80000000) /* Show line count of changes */
41 #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
42 #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
43 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
44 #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
45 #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
@@ -1918,12 +1919,18 @@
1919 if( (diffFlags & DIFF_NOOPT)==0 ){
1920 diff_optimize(&c);
1921 }
1922
1923 if( pOut ){
1924 if( diffFlags & DIFF_NUMSTAT ){
1925 int nDel = 0, nIns = 0, i;
1926 for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
1927 nDel += c.aEdit[i+1];
1928 nIns += c.aEdit[i+2];
1929 }
1930 blob_appendf(pOut, "%10d %10d", nIns, nDel);
1931 }else if( diffFlags & DIFF_SIDEBYSIDE ){
1932 sbsDiff(&c, pOut, pRe, diffFlags);
1933 }else{
1934 contextDiff(&c, pOut, pRe, diffFlags);
1935 }
1936 fossil_free(c.aFrom);
@@ -1948,10 +1955,11 @@
1955 ** -c|--context N N lines of context. DIFF_CONTEXT_MASK
1956 ** --html Format for HTML DIFF_HTML
1957 ** --invert Invert the diff DIFF_INVERT
1958 ** -n|--linenum Show line numbers DIFF_LINENO
1959 ** --noopt Disable optimization DIFF_NOOPT
1960 ** --numstat Show change counts DIFF_NUMSTAT
1961 ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
1962 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
1963 ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
1964 ** -W|--width N N character lines. DIFF_WIDTH_MASK
1965 ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
@@ -1985,10 +1993,11 @@
1993 diffFlags |= f;
1994 }
1995 if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
1996 if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
1997 if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
1998 if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT;
1999 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
2000 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
2001 return diffFlags;
2002 }
2003
2004
+30 -15
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -107,11 +107,11 @@
107107
108108
/*
109109
** Print the "Index:" message that patches wants to see at the top of a diff.
110110
*/
111111
void diff_print_index(const char *zFile, u64 diffFlags){
112
- if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){
112
+ if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF|DIFF_NUMSTAT))==0 ){
113113
char *z = mprintf("Index: %s\n%.66c\n", zFile, '=');
114114
fossil_print("%s", z);
115115
fossil_free(z);
116116
}
117117
}
@@ -204,12 +204,16 @@
204204
text_diff(&file2, pFile1, &out, 0, diffFlags);
205205
}else{
206206
text_diff(pFile1, &file2, &out, 0, diffFlags);
207207
}
208208
if( blob_size(&out) ){
209
- diff_print_filenames(zName, zName2, diffFlags);
210
- fossil_print("%s\n", blob_str(&out));
209
+ if( diffFlags & DIFF_NUMSTAT ){
210
+ fossil_print("%s %s\n", blob_str(&out), zName);
211
+ }else{
212
+ diff_print_filenames(zName, zName2, diffFlags);
213
+ fossil_print("%s\n", blob_str(&out));
214
+ }
211215
}
212216
blob_reset(&out);
213217
}
214218
215219
/* Release memory resources */
@@ -310,13 +314,17 @@
310314
if( zDiffCmd==0 ){
311315
Blob out; /* Diff output text */
312316
313317
blob_zero(&out);
314318
text_diff(pFile1, pFile2, &out, 0, diffFlags);
315
- diff_print_filenames(zName, zName, diffFlags);
316
- fossil_print("%s\n", blob_str(&out));
317
-
319
+ if( diffFlags & DIFF_NUMSTAT ){
320
+ fossil_print("%s %s\n", blob_str(&out), zName);
321
+ }else{
322
+ diff_print_filenames(zName, zName, diffFlags);
323
+ fossil_print("%s\n", blob_str(&out));
324
+ }
325
+
318326
/* Release memory resources */
319327
blob_reset(&out);
320328
}else{
321329
Blob cmd;
322330
Blob temp1;
@@ -396,12 +404,14 @@
396404
){
397405
int vid;
398406
Blob sql;
399407
Stmt q;
400408
int asNewFile; /* Treat non-existant files as empty files */
409
+ int isNumStat; /* True for --numstat */
401410
402
- asNewFile = (diffFlags & DIFF_VERBOSE)!=0;
411
+ asNewFile = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0;
412
+ isNumStat = (diffFlags & DIFF_NUMSTAT)!=0;
403413
vid = db_lget_int("checkout", 0);
404414
vfile_check_signature(vid, CKSIG_ENOTFILE);
405415
blob_zero(&sql);
406416
db_begin_transaction();
407417
if( zFrom ){
@@ -461,25 +471,25 @@
461471
blob_set(&fname, g.zLocalRoot);
462472
blob_append(&fname, zPathname, -1);
463473
}
464474
zFullName = blob_str(&fname);
465475
if( isDeleted ){
466
- fossil_print("DELETED %s\n", zPathname);
476
+ if( !isNumStat ){ fossil_print("DELETED %s\n", zPathname); }
467477
if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
468478
}else if( file_access(zFullName, F_OK) ){
469
- fossil_print("MISSING %s\n", zPathname);
479
+ if( !isNumStat ){ fossil_print("MISSING %s\n", zPathname); }
470480
if( !asNewFile ){ showDiff = 0; }
471481
}else if( isNew ){
472
- fossil_print("ADDED %s\n", zPathname);
482
+ if( !isNumStat ){ fossil_print("ADDED %s\n", zPathname); }
473483
srcid = 0;
474484
if( !asNewFile ){ showDiff = 0; }
475485
}else if( isChnged==3 ){
476
- fossil_print("ADDED_BY_MERGE %s\n", zPathname);
486
+ if( !isNumStat ){ fossil_print("ADDED_BY_MERGE %s\n", zPathname); }
477487
srcid = 0;
478488
if( !asNewFile ){ showDiff = 0; }
479489
}else if( isChnged==5 ){
480
- fossil_print("ADDED_BY_INTEGRATE %s\n", zPathname);
490
+ if( !isNumStat ){ fossil_print("ADDED_BY_INTEGRATE %s\n", zPathname); }
481491
srcid = 0;
482492
if( !asNewFile ){ showDiff = 0; }
483493
}
484494
if( showDiff ){
485495
Blob content;
@@ -613,11 +623,11 @@
613623
u64 diffFlags,
614624
FileDirList *pFileDir
615625
){
616626
Manifest *pFrom, *pTo;
617627
ManifestFile *pFromFile, *pToFile;
618
- int asNewFlag = (diffFlags & DIFF_VERBOSE)!=0 ? 1 : 0;
628
+ int asNewFlag = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0 ? 1 : 0;
619629
620630
pFrom = manifest_get_by_name(zFrom, 0);
621631
manifest_file_rewind(pFrom);
622632
pFromFile = manifest_file_next(pFrom,0);
623633
pTo = manifest_get_by_name(zTo, 0);
@@ -633,20 +643,24 @@
633643
}else{
634644
cmp = fossil_strcmp(pFromFile->zName, pToFile->zName);
635645
}
636646
if( cmp<0 ){
637647
if( file_dir_match(pFileDir, pFromFile->zName) ){
638
- fossil_print("DELETED %s\n", pFromFile->zName);
648
+ if( (diffFlags & DIFF_NUMSTAT)==0 ){
649
+ fossil_print("DELETED %s\n", pFromFile->zName);
650
+ }
639651
if( asNewFlag ){
640652
diff_manifest_entry(pFromFile, 0, zDiffCmd, zBinGlob,
641653
fIncludeBinary, diffFlags);
642654
}
643655
}
644656
pFromFile = manifest_file_next(pFrom,0);
645657
}else if( cmp>0 ){
646658
if( file_dir_match(pFileDir, pToFile->zName) ){
647
- fossil_print("ADDED %s\n", pToFile->zName);
659
+ if( (diffFlags & DIFF_NUMSTAT)==0 ){
660
+ fossil_print("ADDED %s\n", pToFile->zName);
661
+ }
648662
if( asNewFlag ){
649663
diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob,
650664
fIncludeBinary, diffFlags);
651665
}
652666
}
@@ -833,10 +847,11 @@
833847
** --diff-binary BOOL Include binary files when using external commands
834848
** --exec-abs-paths Force absolute path names with external commands.
835849
** --exec-rel-paths Force relative path names with external commands.
836850
** --from|-r VERSION Select VERSION as source for the diff
837851
** --internal|-i Use internal diff logic
852
+** --numstat Show only the number of lines delete and added
838853
** --side-by-side|-y Side-by-side diff
839854
** --strip-trailing-cr Strip trailing CR
840855
** --tk Launch a Tcl/Tk GUI for display
841856
** --to VERSION Select VERSION as target for the diff
842857
** --undo Diff against the "undo" buffer
843858
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -107,11 +107,11 @@
107
108 /*
109 ** Print the "Index:" message that patches wants to see at the top of a diff.
110 */
111 void diff_print_index(const char *zFile, u64 diffFlags){
112 if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){
113 char *z = mprintf("Index: %s\n%.66c\n", zFile, '=');
114 fossil_print("%s", z);
115 fossil_free(z);
116 }
117 }
@@ -204,12 +204,16 @@
204 text_diff(&file2, pFile1, &out, 0, diffFlags);
205 }else{
206 text_diff(pFile1, &file2, &out, 0, diffFlags);
207 }
208 if( blob_size(&out) ){
209 diff_print_filenames(zName, zName2, diffFlags);
210 fossil_print("%s\n", blob_str(&out));
 
 
 
 
211 }
212 blob_reset(&out);
213 }
214
215 /* Release memory resources */
@@ -310,13 +314,17 @@
310 if( zDiffCmd==0 ){
311 Blob out; /* Diff output text */
312
313 blob_zero(&out);
314 text_diff(pFile1, pFile2, &out, 0, diffFlags);
315 diff_print_filenames(zName, zName, diffFlags);
316 fossil_print("%s\n", blob_str(&out));
317
 
 
 
 
318 /* Release memory resources */
319 blob_reset(&out);
320 }else{
321 Blob cmd;
322 Blob temp1;
@@ -396,12 +404,14 @@
396 ){
397 int vid;
398 Blob sql;
399 Stmt q;
400 int asNewFile; /* Treat non-existant files as empty files */
 
401
402 asNewFile = (diffFlags & DIFF_VERBOSE)!=0;
 
403 vid = db_lget_int("checkout", 0);
404 vfile_check_signature(vid, CKSIG_ENOTFILE);
405 blob_zero(&sql);
406 db_begin_transaction();
407 if( zFrom ){
@@ -461,25 +471,25 @@
461 blob_set(&fname, g.zLocalRoot);
462 blob_append(&fname, zPathname, -1);
463 }
464 zFullName = blob_str(&fname);
465 if( isDeleted ){
466 fossil_print("DELETED %s\n", zPathname);
467 if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
468 }else if( file_access(zFullName, F_OK) ){
469 fossil_print("MISSING %s\n", zPathname);
470 if( !asNewFile ){ showDiff = 0; }
471 }else if( isNew ){
472 fossil_print("ADDED %s\n", zPathname);
473 srcid = 0;
474 if( !asNewFile ){ showDiff = 0; }
475 }else if( isChnged==3 ){
476 fossil_print("ADDED_BY_MERGE %s\n", zPathname);
477 srcid = 0;
478 if( !asNewFile ){ showDiff = 0; }
479 }else if( isChnged==5 ){
480 fossil_print("ADDED_BY_INTEGRATE %s\n", zPathname);
481 srcid = 0;
482 if( !asNewFile ){ showDiff = 0; }
483 }
484 if( showDiff ){
485 Blob content;
@@ -613,11 +623,11 @@
613 u64 diffFlags,
614 FileDirList *pFileDir
615 ){
616 Manifest *pFrom, *pTo;
617 ManifestFile *pFromFile, *pToFile;
618 int asNewFlag = (diffFlags & DIFF_VERBOSE)!=0 ? 1 : 0;
619
620 pFrom = manifest_get_by_name(zFrom, 0);
621 manifest_file_rewind(pFrom);
622 pFromFile = manifest_file_next(pFrom,0);
623 pTo = manifest_get_by_name(zTo, 0);
@@ -633,20 +643,24 @@
633 }else{
634 cmp = fossil_strcmp(pFromFile->zName, pToFile->zName);
635 }
636 if( cmp<0 ){
637 if( file_dir_match(pFileDir, pFromFile->zName) ){
638 fossil_print("DELETED %s\n", pFromFile->zName);
 
 
639 if( asNewFlag ){
640 diff_manifest_entry(pFromFile, 0, zDiffCmd, zBinGlob,
641 fIncludeBinary, diffFlags);
642 }
643 }
644 pFromFile = manifest_file_next(pFrom,0);
645 }else if( cmp>0 ){
646 if( file_dir_match(pFileDir, pToFile->zName) ){
647 fossil_print("ADDED %s\n", pToFile->zName);
 
 
648 if( asNewFlag ){
649 diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob,
650 fIncludeBinary, diffFlags);
651 }
652 }
@@ -833,10 +847,11 @@
833 ** --diff-binary BOOL Include binary files when using external commands
834 ** --exec-abs-paths Force absolute path names with external commands.
835 ** --exec-rel-paths Force relative path names with external commands.
836 ** --from|-r VERSION Select VERSION as source for the diff
837 ** --internal|-i Use internal diff logic
 
838 ** --side-by-side|-y Side-by-side diff
839 ** --strip-trailing-cr Strip trailing CR
840 ** --tk Launch a Tcl/Tk GUI for display
841 ** --to VERSION Select VERSION as target for the diff
842 ** --undo Diff against the "undo" buffer
843
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -107,11 +107,11 @@
107
108 /*
109 ** Print the "Index:" message that patches wants to see at the top of a diff.
110 */
111 void diff_print_index(const char *zFile, u64 diffFlags){
112 if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF|DIFF_NUMSTAT))==0 ){
113 char *z = mprintf("Index: %s\n%.66c\n", zFile, '=');
114 fossil_print("%s", z);
115 fossil_free(z);
116 }
117 }
@@ -204,12 +204,16 @@
204 text_diff(&file2, pFile1, &out, 0, diffFlags);
205 }else{
206 text_diff(pFile1, &file2, &out, 0, diffFlags);
207 }
208 if( blob_size(&out) ){
209 if( diffFlags & DIFF_NUMSTAT ){
210 fossil_print("%s %s\n", blob_str(&out), zName);
211 }else{
212 diff_print_filenames(zName, zName2, diffFlags);
213 fossil_print("%s\n", blob_str(&out));
214 }
215 }
216 blob_reset(&out);
217 }
218
219 /* Release memory resources */
@@ -310,13 +314,17 @@
314 if( zDiffCmd==0 ){
315 Blob out; /* Diff output text */
316
317 blob_zero(&out);
318 text_diff(pFile1, pFile2, &out, 0, diffFlags);
319 if( diffFlags & DIFF_NUMSTAT ){
320 fossil_print("%s %s\n", blob_str(&out), zName);
321 }else{
322 diff_print_filenames(zName, zName, diffFlags);
323 fossil_print("%s\n", blob_str(&out));
324 }
325
326 /* Release memory resources */
327 blob_reset(&out);
328 }else{
329 Blob cmd;
330 Blob temp1;
@@ -396,12 +404,14 @@
404 ){
405 int vid;
406 Blob sql;
407 Stmt q;
408 int asNewFile; /* Treat non-existant files as empty files */
409 int isNumStat; /* True for --numstat */
410
411 asNewFile = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0;
412 isNumStat = (diffFlags & DIFF_NUMSTAT)!=0;
413 vid = db_lget_int("checkout", 0);
414 vfile_check_signature(vid, CKSIG_ENOTFILE);
415 blob_zero(&sql);
416 db_begin_transaction();
417 if( zFrom ){
@@ -461,25 +471,25 @@
471 blob_set(&fname, g.zLocalRoot);
472 blob_append(&fname, zPathname, -1);
473 }
474 zFullName = blob_str(&fname);
475 if( isDeleted ){
476 if( !isNumStat ){ fossil_print("DELETED %s\n", zPathname); }
477 if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
478 }else if( file_access(zFullName, F_OK) ){
479 if( !isNumStat ){ fossil_print("MISSING %s\n", zPathname); }
480 if( !asNewFile ){ showDiff = 0; }
481 }else if( isNew ){
482 if( !isNumStat ){ fossil_print("ADDED %s\n", zPathname); }
483 srcid = 0;
484 if( !asNewFile ){ showDiff = 0; }
485 }else if( isChnged==3 ){
486 if( !isNumStat ){ fossil_print("ADDED_BY_MERGE %s\n", zPathname); }
487 srcid = 0;
488 if( !asNewFile ){ showDiff = 0; }
489 }else if( isChnged==5 ){
490 if( !isNumStat ){ fossil_print("ADDED_BY_INTEGRATE %s\n", zPathname); }
491 srcid = 0;
492 if( !asNewFile ){ showDiff = 0; }
493 }
494 if( showDiff ){
495 Blob content;
@@ -613,11 +623,11 @@
623 u64 diffFlags,
624 FileDirList *pFileDir
625 ){
626 Manifest *pFrom, *pTo;
627 ManifestFile *pFromFile, *pToFile;
628 int asNewFlag = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0 ? 1 : 0;
629
630 pFrom = manifest_get_by_name(zFrom, 0);
631 manifest_file_rewind(pFrom);
632 pFromFile = manifest_file_next(pFrom,0);
633 pTo = manifest_get_by_name(zTo, 0);
@@ -633,20 +643,24 @@
643 }else{
644 cmp = fossil_strcmp(pFromFile->zName, pToFile->zName);
645 }
646 if( cmp<0 ){
647 if( file_dir_match(pFileDir, pFromFile->zName) ){
648 if( (diffFlags & DIFF_NUMSTAT)==0 ){
649 fossil_print("DELETED %s\n", pFromFile->zName);
650 }
651 if( asNewFlag ){
652 diff_manifest_entry(pFromFile, 0, zDiffCmd, zBinGlob,
653 fIncludeBinary, diffFlags);
654 }
655 }
656 pFromFile = manifest_file_next(pFrom,0);
657 }else if( cmp>0 ){
658 if( file_dir_match(pFileDir, pToFile->zName) ){
659 if( (diffFlags & DIFF_NUMSTAT)==0 ){
660 fossil_print("ADDED %s\n", pToFile->zName);
661 }
662 if( asNewFlag ){
663 diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob,
664 fIncludeBinary, diffFlags);
665 }
666 }
@@ -833,10 +847,11 @@
847 ** --diff-binary BOOL Include binary files when using external commands
848 ** --exec-abs-paths Force absolute path names with external commands.
849 ** --exec-rel-paths Force relative path names with external commands.
850 ** --from|-r VERSION Select VERSION as source for the diff
851 ** --internal|-i Use internal diff logic
852 ** --numstat Show only the number of lines delete and added
853 ** --side-by-side|-y Side-by-side diff
854 ** --strip-trailing-cr Strip trailing CR
855 ** --tk Launch a Tcl/Tk GUI for display
856 ** --to VERSION Select VERSION as target for the diff
857 ** --undo Diff against the "undo" buffer
858

Keyboard Shortcuts

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