Fossil SCM

Try to fix it more better so it'll work with CLI diffs. Add --ignore-space-at-eol option (name taken from Git) to diff cmd.

joel 2014-03-03 08:22 diff-eolws
Commit 554607d35b835ba217c0aa59dd9b9aaf8d410903
2 files changed +9 -5 +17 -13
+9 -5
--- src/diff.c
+++ src/diff.c
@@ -1785,23 +1785,27 @@
17851785
return 0;
17861786
}
17871787
17881788
/* Compute the difference */
17891789
diff_all(&c);
1790
+ if( ignoreEolWs && c.nEdit==6 && c.aEdit[1]==0 && c.aEdit[2]==0 ){
1791
+ fossil_free(c.aFrom);
1792
+ fossil_free(c.aTo);
1793
+ fossil_free(c.aEdit);
1794
+ if( pOut ) diff_errmsg(pOut, DIFF_EOLWS_ONLY, diffFlags);
1795
+ return 0;
1796
+ }
17901797
if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){
17911798
int i, m, n;
17921799
int *a = c.aEdit;
17931800
int mx = c.nEdit;
17941801
for(i=m=n=0; i<mx; i+=3){ m += a[i]; n += a[i+1]+a[i+2]; }
1795
- if( n==0 || n>10000 ){
1802
+ if( n>10000 ){
17961803
fossil_free(c.aFrom);
17971804
fossil_free(c.aTo);
17981805
fossil_free(c.aEdit);
1799
- if( pOut ) {
1800
- diff_errmsg(pOut, n==0 ? DIFF_EOLWS_ONLY : DIFF_TOO_MANY_CHANGES,
1801
- diffFlags);
1802
- }
1806
+ if( pOut ) diff_errmsg(pOut, DIFF_TOO_MANY_CHANGES, diffFlags);
18031807
return 0;
18041808
}
18051809
}
18061810
if( (diffFlags & DIFF_NOOPT)==0 ){
18071811
diff_optimize(&c);
18081812
--- src/diff.c
+++ src/diff.c
@@ -1785,23 +1785,27 @@
1785 return 0;
1786 }
1787
1788 /* Compute the difference */
1789 diff_all(&c);
 
 
 
 
 
 
 
1790 if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){
1791 int i, m, n;
1792 int *a = c.aEdit;
1793 int mx = c.nEdit;
1794 for(i=m=n=0; i<mx; i+=3){ m += a[i]; n += a[i+1]+a[i+2]; }
1795 if( n==0 || n>10000 ){
1796 fossil_free(c.aFrom);
1797 fossil_free(c.aTo);
1798 fossil_free(c.aEdit);
1799 if( pOut ) {
1800 diff_errmsg(pOut, n==0 ? DIFF_EOLWS_ONLY : DIFF_TOO_MANY_CHANGES,
1801 diffFlags);
1802 }
1803 return 0;
1804 }
1805 }
1806 if( (diffFlags & DIFF_NOOPT)==0 ){
1807 diff_optimize(&c);
1808
--- src/diff.c
+++ src/diff.c
@@ -1785,23 +1785,27 @@
1785 return 0;
1786 }
1787
1788 /* Compute the difference */
1789 diff_all(&c);
1790 if( ignoreEolWs && c.nEdit==6 && c.aEdit[1]==0 && c.aEdit[2]==0 ){
1791 fossil_free(c.aFrom);
1792 fossil_free(c.aTo);
1793 fossil_free(c.aEdit);
1794 if( pOut ) diff_errmsg(pOut, DIFF_EOLWS_ONLY, diffFlags);
1795 return 0;
1796 }
1797 if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){
1798 int i, m, n;
1799 int *a = c.aEdit;
1800 int mx = c.nEdit;
1801 for(i=m=n=0; i<mx; i+=3){ m += a[i]; n += a[i+1]+a[i+2]; }
1802 if( n>10000 ){
1803 fossil_free(c.aFrom);
1804 fossil_free(c.aTo);
1805 fossil_free(c.aEdit);
1806 if( pOut ) diff_errmsg(pOut, DIFF_TOO_MANY_CHANGES, diffFlags);
 
 
 
1807 return 0;
1808 }
1809 }
1810 if( (diffFlags & DIFF_NOOPT)==0 ){
1811 diff_optimize(&c);
1812
+17 -13
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1079,23 +1079,24 @@
10791079
** The "--binary" option causes files matching the glob PATTERN to be treated
10801080
** as binary when considering if they should be used with external diff program.
10811081
** This option overrides the "binary-glob" setting.
10821082
**
10831083
** Options:
1084
-** --binary PATTERN Treat files that match the glob PATTERN as binary
1085
-** --branch BRANCH Show diff of all changes on BRANCH
1086
-** --brief Show filenames only
1087
-** --context|-c N Use N lines of context
1088
-** --diff-binary BOOL Include binary files when using external commands
1089
-** --from|-r VERSION select VERSION as source for the diff
1090
-** --internal|-i use internal diff logic
1091
-** --side-by-side|-y side-by-side diff
1092
-** --tk Launch a Tcl/Tk GUI for display
1093
-** --to VERSION select VERSION as target for the diff
1094
-** --unified unified diff
1095
-** -v|--verbose output complete text of added or deleted files
1096
-** -W|--width Width of lines in side-by-side diff
1084
+** --binary PATTERN Treat files that match the glob PATTERN as binary
1085
+** --branch BRANCH Show diff of all changes on BRANCH
1086
+** --brief Show filenames only
1087
+** --context|-c N Use N lines of context
1088
+** --diff-binary BOOL Include binary files when using external commands
1089
+** --from|-r VERSION select VERSION as source for the diff
1090
+** --ignore-space-at-eol Ignore changes to end-of-line whitespace
1091
+** --internal|-i use internal diff logic
1092
+** --side-by-side|-y side-by-side diff
1093
+** --tk Launch a Tcl/Tk GUI for display
1094
+** --to VERSION select VERSION as target for the diff
1095
+** --unified unified diff
1096
+** -v|--verbose output complete text of added or deleted files
1097
+** -W|--width Width of lines in side-by-side diff
10971098
*/
10981099
void diff_cmd(void){
10991100
int isGDiff; /* True for gdiff. False for normal diff */
11001101
int isInternDiff; /* True for internal diff */
11011102
int verboseFlag; /* True if -v or --verbose flag is used */
@@ -1121,10 +1122,13 @@
11211122
verboseFlag = find_option("verbose","v",0)!=0;
11221123
if( !verboseFlag ){
11231124
verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
11241125
}
11251126
if( verboseFlag ) diffFlags |= DIFF_VERBOSE;
1127
+ if( find_option("ignore-space-at-eol",0,0)!=0 ) {
1128
+ diffFlags |= DIFF_IGNORE_EOLWS;
1129
+ }
11261130
11271131
if( zBranch ){
11281132
if( zTo || zFrom ){
11291133
fossil_fatal("cannot use --from or --to with --branch");
11301134
}
11311135
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1079,23 +1079,24 @@
1079 ** The "--binary" option causes files matching the glob PATTERN to be treated
1080 ** as binary when considering if they should be used with external diff program.
1081 ** This option overrides the "binary-glob" setting.
1082 **
1083 ** Options:
1084 ** --binary PATTERN Treat files that match the glob PATTERN as binary
1085 ** --branch BRANCH Show diff of all changes on BRANCH
1086 ** --brief Show filenames only
1087 ** --context|-c N Use N lines of context
1088 ** --diff-binary BOOL Include binary files when using external commands
1089 ** --from|-r VERSION select VERSION as source for the diff
1090 ** --internal|-i use internal diff logic
1091 ** --side-by-side|-y side-by-side diff
1092 ** --tk Launch a Tcl/Tk GUI for display
1093 ** --to VERSION select VERSION as target for the diff
1094 ** --unified unified diff
1095 ** -v|--verbose output complete text of added or deleted files
1096 ** -W|--width Width of lines in side-by-side diff
 
1097 */
1098 void diff_cmd(void){
1099 int isGDiff; /* True for gdiff. False for normal diff */
1100 int isInternDiff; /* True for internal diff */
1101 int verboseFlag; /* True if -v or --verbose flag is used */
@@ -1121,10 +1122,13 @@
1121 verboseFlag = find_option("verbose","v",0)!=0;
1122 if( !verboseFlag ){
1123 verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
1124 }
1125 if( verboseFlag ) diffFlags |= DIFF_VERBOSE;
 
 
 
1126
1127 if( zBranch ){
1128 if( zTo || zFrom ){
1129 fossil_fatal("cannot use --from or --to with --branch");
1130 }
1131
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1079,23 +1079,24 @@
1079 ** The "--binary" option causes files matching the glob PATTERN to be treated
1080 ** as binary when considering if they should be used with external diff program.
1081 ** This option overrides the "binary-glob" setting.
1082 **
1083 ** Options:
1084 ** --binary PATTERN Treat files that match the glob PATTERN as binary
1085 ** --branch BRANCH Show diff of all changes on BRANCH
1086 ** --brief Show filenames only
1087 ** --context|-c N Use N lines of context
1088 ** --diff-binary BOOL Include binary files when using external commands
1089 ** --from|-r VERSION select VERSION as source for the diff
1090 ** --ignore-space-at-eol Ignore changes to end-of-line whitespace
1091 ** --internal|-i use internal diff logic
1092 ** --side-by-side|-y side-by-side diff
1093 ** --tk Launch a Tcl/Tk GUI for display
1094 ** --to VERSION select VERSION as target for the diff
1095 ** --unified unified diff
1096 ** -v|--verbose output complete text of added or deleted files
1097 ** -W|--width Width of lines in side-by-side diff
1098 */
1099 void diff_cmd(void){
1100 int isGDiff; /* True for gdiff. False for normal diff */
1101 int isInternDiff; /* True for internal diff */
1102 int verboseFlag; /* True if -v or --verbose flag is used */
@@ -1121,10 +1122,13 @@
1122 verboseFlag = find_option("verbose","v",0)!=0;
1123 if( !verboseFlag ){
1124 verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
1125 }
1126 if( verboseFlag ) diffFlags |= DIFF_VERBOSE;
1127 if( find_option("ignore-space-at-eol",0,0)!=0 ) {
1128 diffFlags |= DIFF_IGNORE_EOLWS;
1129 }
1130
1131 if( zBranch ){
1132 if( zTo || zFrom ){
1133 fossil_fatal("cannot use --from or --to with --branch");
1134 }
1135

Keyboard Shortcuts

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