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.
Commit
554607d35b835ba217c0aa59dd9b9aaf8d410903
Parent
8f885df20975e89…
2 files changed
+9
-5
+17
-13
+9
-5
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -1785,23 +1785,27 @@ | ||
| 1785 | 1785 | return 0; |
| 1786 | 1786 | } |
| 1787 | 1787 | |
| 1788 | 1788 | /* Compute the difference */ |
| 1789 | 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 | + } | |
| 1790 | 1797 | if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){ |
| 1791 | 1798 | int i, m, n; |
| 1792 | 1799 | int *a = c.aEdit; |
| 1793 | 1800 | int mx = c.nEdit; |
| 1794 | 1801 | 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 ){ | |
| 1796 | 1803 | fossil_free(c.aFrom); |
| 1797 | 1804 | fossil_free(c.aTo); |
| 1798 | 1805 | 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); | |
| 1803 | 1807 | return 0; |
| 1804 | 1808 | } |
| 1805 | 1809 | } |
| 1806 | 1810 | if( (diffFlags & DIFF_NOOPT)==0 ){ |
| 1807 | 1811 | diff_optimize(&c); |
| 1808 | 1812 |
| --- 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 @@ | ||
| 1079 | 1079 | ** The "--binary" option causes files matching the glob PATTERN to be treated |
| 1080 | 1080 | ** as binary when considering if they should be used with external diff program. |
| 1081 | 1081 | ** This option overrides the "binary-glob" setting. |
| 1082 | 1082 | ** |
| 1083 | 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 | |
| 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 | |
| 1097 | 1098 | */ |
| 1098 | 1099 | void diff_cmd(void){ |
| 1099 | 1100 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 1100 | 1101 | int isInternDiff; /* True for internal diff */ |
| 1101 | 1102 | int verboseFlag; /* True if -v or --verbose flag is used */ |
| @@ -1121,10 +1122,13 @@ | ||
| 1121 | 1122 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1122 | 1123 | if( !verboseFlag ){ |
| 1123 | 1124 | verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */ |
| 1124 | 1125 | } |
| 1125 | 1126 | if( verboseFlag ) diffFlags |= DIFF_VERBOSE; |
| 1127 | + if( find_option("ignore-space-at-eol",0,0)!=0 ) { | |
| 1128 | + diffFlags |= DIFF_IGNORE_EOLWS; | |
| 1129 | + } | |
| 1126 | 1130 | |
| 1127 | 1131 | if( zBranch ){ |
| 1128 | 1132 | if( zTo || zFrom ){ |
| 1129 | 1133 | fossil_fatal("cannot use --from or --to with --branch"); |
| 1130 | 1134 | } |
| 1131 | 1135 |
| --- 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 |