Fossil SCM
Implement --strip-trailing-cr option
Commit
4e6cfaf8f85c787e8f7dc84d4a9b326e853388a9
Parent
466f8de3c2cd734…
2 files changed
+5
+1
+5
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -40,10 +40,11 @@ | ||
| 40 | 40 | #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ |
| 41 | 41 | #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */ |
| 42 | 42 | #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */ |
| 43 | 43 | #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */ |
| 44 | 44 | #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */ |
| 45 | +#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */ | |
| 45 | 46 | |
| 46 | 47 | /* |
| 47 | 48 | ** These error messages are shared in multiple locations. They are defined |
| 48 | 49 | ** here for consistency. |
| 49 | 50 | */ |
| @@ -168,10 +169,12 @@ | ||
| 168 | 169 | k = j; |
| 169 | 170 | s = 0; |
| 170 | 171 | indent = 0; |
| 171 | 172 | if( diffFlags & DIFF_IGNORE_EOLWS ){ |
| 172 | 173 | while( k>0 && fossil_isspace(z[k-1]) ){ k--; } |
| 174 | + }else if( diffFlags & DIFF_STRIP_EOLCR ){ | |
| 175 | + if( k>0 && z[k-1]=='\r' ){ k--; } | |
| 173 | 176 | } |
| 174 | 177 | if( diffFlags & DIFF_IGNORE_SOLWS ){ |
| 175 | 178 | while( s<k && fossil_isspace(z[s]) ){ |
| 176 | 179 | if( z[s]=='\t' ){ |
| 177 | 180 | indent = ((indent+9)/8)*8; |
| @@ -1868,10 +1871,11 @@ | ||
| 1868 | 1871 | ** --ignore-space-at-eol Ignore eol-whitespaces DIFF_IGNORE_EOLWS |
| 1869 | 1872 | ** --ignore-space-at-sol Ignore sol-whitespaces DIFF_IGNORE_SOLWS |
| 1870 | 1873 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1871 | 1874 | ** --noopt Disable optimization DIFF_NOOPT |
| 1872 | 1875 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1876 | +** --strip-trailing-cr Strip trailing CR DIFF_IGNORE_EOLCR | |
| 1873 | 1877 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 1874 | 1878 | ** -w Ignore all whitespaces DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS |
| 1875 | 1879 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1876 | 1880 | */ |
| 1877 | 1881 | u64 diff_options(void){ |
| @@ -1890,10 +1894,11 @@ | ||
| 1890 | 1894 | diffFlags |= f; |
| 1891 | 1895 | } |
| 1892 | 1896 | if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML; |
| 1893 | 1897 | if( find_option("ignore-space-at-sol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_SOLWS; |
| 1894 | 1898 | if( find_option("ignore-space-at-eol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS; |
| 1899 | + if( find_option("strip-trailing-cr",0,0)!=0 ) diffFlags |= DIFF_STRIP_EOLCR; | |
| 1895 | 1900 | if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS); |
| 1896 | 1901 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 1897 | 1902 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 1898 | 1903 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 1899 | 1904 | if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF; |
| 1900 | 1905 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -40,10 +40,11 @@ | |
| 40 | #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ |
| 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 | |
| 46 | /* |
| 47 | ** These error messages are shared in multiple locations. They are defined |
| 48 | ** here for consistency. |
| 49 | */ |
| @@ -168,10 +169,12 @@ | |
| 168 | k = j; |
| 169 | s = 0; |
| 170 | indent = 0; |
| 171 | if( diffFlags & DIFF_IGNORE_EOLWS ){ |
| 172 | while( k>0 && fossil_isspace(z[k-1]) ){ k--; } |
| 173 | } |
| 174 | if( diffFlags & DIFF_IGNORE_SOLWS ){ |
| 175 | while( s<k && fossil_isspace(z[s]) ){ |
| 176 | if( z[s]=='\t' ){ |
| 177 | indent = ((indent+9)/8)*8; |
| @@ -1868,10 +1871,11 @@ | |
| 1868 | ** --ignore-space-at-eol Ignore eol-whitespaces DIFF_IGNORE_EOLWS |
| 1869 | ** --ignore-space-at-sol Ignore sol-whitespaces DIFF_IGNORE_SOLWS |
| 1870 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1871 | ** --noopt Disable optimization DIFF_NOOPT |
| 1872 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1873 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 1874 | ** -w Ignore all whitespaces DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS |
| 1875 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1876 | */ |
| 1877 | u64 diff_options(void){ |
| @@ -1890,10 +1894,11 @@ | |
| 1890 | diffFlags |= f; |
| 1891 | } |
| 1892 | if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML; |
| 1893 | if( find_option("ignore-space-at-sol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_SOLWS; |
| 1894 | if( find_option("ignore-space-at-eol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS; |
| 1895 | if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS); |
| 1896 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 1897 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 1898 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 1899 | if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF; |
| 1900 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -40,10 +40,11 @@ | |
| 40 | #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ |
| 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 */ |
| 46 | |
| 47 | /* |
| 48 | ** These error messages are shared in multiple locations. They are defined |
| 49 | ** here for consistency. |
| 50 | */ |
| @@ -168,10 +169,12 @@ | |
| 169 | k = j; |
| 170 | s = 0; |
| 171 | indent = 0; |
| 172 | if( diffFlags & DIFF_IGNORE_EOLWS ){ |
| 173 | while( k>0 && fossil_isspace(z[k-1]) ){ k--; } |
| 174 | }else if( diffFlags & DIFF_STRIP_EOLCR ){ |
| 175 | if( k>0 && z[k-1]=='\r' ){ k--; } |
| 176 | } |
| 177 | if( diffFlags & DIFF_IGNORE_SOLWS ){ |
| 178 | while( s<k && fossil_isspace(z[s]) ){ |
| 179 | if( z[s]=='\t' ){ |
| 180 | indent = ((indent+9)/8)*8; |
| @@ -1868,10 +1871,11 @@ | |
| 1871 | ** --ignore-space-at-eol Ignore eol-whitespaces DIFF_IGNORE_EOLWS |
| 1872 | ** --ignore-space-at-sol Ignore sol-whitespaces DIFF_IGNORE_SOLWS |
| 1873 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1874 | ** --noopt Disable optimization DIFF_NOOPT |
| 1875 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1876 | ** --strip-trailing-cr Strip trailing CR DIFF_IGNORE_EOLCR |
| 1877 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 1878 | ** -w Ignore all whitespaces DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS |
| 1879 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1880 | */ |
| 1881 | u64 diff_options(void){ |
| @@ -1890,10 +1894,11 @@ | |
| 1894 | diffFlags |= f; |
| 1895 | } |
| 1896 | if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML; |
| 1897 | if( find_option("ignore-space-at-sol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_SOLWS; |
| 1898 | if( find_option("ignore-space-at-eol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS; |
| 1899 | if( find_option("strip-trailing-cr",0,0)!=0 ) diffFlags |= DIFF_STRIP_EOLCR; |
| 1900 | if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS); |
| 1901 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 1902 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 1903 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 1904 | if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF; |
| 1905 |
+1
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -1099,10 +1099,11 @@ | ||
| 1099 | 1099 | ** --from|-r VERSION select VERSION as source for the diff |
| 1100 | 1100 | ** --ignore-space-at-eol Ignore changes to end-of-line whitespace |
| 1101 | 1101 | ** --ignore-space-at-sol Ignore changes to start-of-line whitespace |
| 1102 | 1102 | ** --internal|-i use internal diff logic |
| 1103 | 1103 | ** --side-by-side|-y side-by-side diff |
| 1104 | +** --strip-trailing-cr Strip trailing CR | |
| 1104 | 1105 | ** --tk Launch a Tcl/Tk GUI for display |
| 1105 | 1106 | ** --to VERSION select VERSION as target for the diff |
| 1106 | 1107 | ** --unified unified diff |
| 1107 | 1108 | ** -v|--verbose output complete text of added or deleted files |
| 1108 | 1109 | ** -w Ignore changes to start-of-line and end-of-line |
| 1109 | 1110 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -1099,10 +1099,11 @@ | |
| 1099 | ** --from|-r VERSION select VERSION as source for the diff |
| 1100 | ** --ignore-space-at-eol Ignore changes to end-of-line whitespace |
| 1101 | ** --ignore-space-at-sol Ignore changes to start-of-line whitespace |
| 1102 | ** --internal|-i use internal diff logic |
| 1103 | ** --side-by-side|-y side-by-side diff |
| 1104 | ** --tk Launch a Tcl/Tk GUI for display |
| 1105 | ** --to VERSION select VERSION as target for the diff |
| 1106 | ** --unified unified diff |
| 1107 | ** -v|--verbose output complete text of added or deleted files |
| 1108 | ** -w Ignore changes to start-of-line and end-of-line |
| 1109 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -1099,10 +1099,11 @@ | |
| 1099 | ** --from|-r VERSION select VERSION as source for the diff |
| 1100 | ** --ignore-space-at-eol Ignore changes to end-of-line whitespace |
| 1101 | ** --ignore-space-at-sol Ignore changes to start-of-line whitespace |
| 1102 | ** --internal|-i use internal diff logic |
| 1103 | ** --side-by-side|-y side-by-side diff |
| 1104 | ** --strip-trailing-cr Strip trailing CR |
| 1105 | ** --tk Launch a Tcl/Tk GUI for display |
| 1106 | ** --to VERSION select VERSION as target for the diff |
| 1107 | ** --unified unified diff |
| 1108 | ** -v|--verbose output complete text of added or deleted files |
| 1109 | ** -w Ignore changes to start-of-line and end-of-line |
| 1110 |