| | @@ -29,10 +29,11 @@ |
| 29 | 29 | ** of the diff output. |
| 30 | 30 | */ |
| 31 | 31 | #define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */ |
| 32 | 32 | #define DIFF_WIDTH_MASK ((u64)0x00ff0000) /* side-by-side column width */ |
| 33 | 33 | #define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */ |
| 34 | +#define DIFF_IGNORE_WSCHG ((u64)0x02000000) /* Ignore whitespace changes */ |
| 34 | 35 | #define DIFF_IGNORE_ALLWS ((u64)0x03000000) /* Ignore all whitespace */ |
| 35 | 36 | #define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */ |
| 36 | 37 | #define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */ |
| 37 | 38 | #define DIFF_INLINE ((u64)0x00000000) /* Inline (not side-by-side) diff */ |
| 38 | 39 | #define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */ |
| | @@ -175,17 +176,31 @@ |
| 175 | 176 | if( k>0 && z[k-1]=='\r' ){ k--; } |
| 176 | 177 | } |
| 177 | 178 | if( diffFlags & DIFF_IGNORE_ALLWS ){ |
| 178 | 179 | while( k>0 && fossil_isspace(z[k-1]) ){ k--; extent++;} |
| 179 | 180 | } |
| 180 | | - if( (diffFlags & DIFF_IGNORE_ALLWS)==DIFF_IGNORE_ALLWS ){ |
| 181 | | - while( s<k && fossil_isspace(z[s]) ){s++; extent++;} |
| 182 | | - for(h=0, x=s; x<k; x++){ |
| 183 | | - if( fossil_isspace(z[x]) ){ |
| 184 | | - ++numws; |
| 185 | | - }else{ |
| 186 | | - h = h ^ (h<<2) ^ z[x]; |
| 181 | + if( diffFlags & DIFF_IGNORE_WSCHG ){ |
| 182 | + if( (diffFlags & DIFF_IGNORE_ALLWS)==DIFF_IGNORE_ALLWS ){ |
| 183 | + while( s<k && fossil_isspace(z[s]) ){s++; extent++;} |
| 184 | + for(h=0, x=s; x<k; x++){ |
| 185 | + if( fossil_isspace(z[x]) ){ |
| 186 | + ++numws; |
| 187 | + }else{ |
| 188 | + h = h ^ (h<<2) ^ z[x]; |
| 189 | + } |
| 190 | + } |
| 191 | + }else{ |
| 192 | + for(h=0, x=0; x<k; x++){ |
| 193 | + if( fossil_isspace(z[x]) ){ |
| 194 | + if( x>0 && !fossil_isspace(z[x-1]) ){ |
| 195 | + ++numws; |
| 196 | + }else{ |
| 197 | + h = h ^ (h<<2) ^ ' '; |
| 198 | + } |
| 199 | + }else{ |
| 200 | + h = h ^ (h<<2) ^ z[x]; |
| 201 | + } |
| 187 | 202 | } |
| 188 | 203 | } |
| 189 | 204 | }else{ |
| 190 | 205 | for(h=0, x=0; x<k; x++){ |
| 191 | 206 | h = h ^ (h<<2) ^ z[x]; |
| | @@ -207,11 +222,12 @@ |
| 207 | 222 | |
| 208 | 223 | /* |
| 209 | 224 | ** Return true if two DLine elements are identical. |
| 210 | 225 | */ |
| 211 | 226 | static int same_dline(DLine *pA, DLine *pB){ |
| 212 | | - return pA->h==pB->h && memcmp(pA->z,pB->z,pA->h & LENGTH_MASK)==0; |
| 227 | + return pA->h==pB->h; // TODO: not quite right, need better hash function. |
| 228 | + //return pA->h==pB->h && memcmp(pA->z,pB->z,pA->h & LENGTH_MASK)==0; |
| 213 | 229 | } |
| 214 | 230 | |
| 215 | 231 | /* |
| 216 | 232 | ** Return true if the regular expression *pRe matches any of the |
| 217 | 233 | ** N dlines |
| | @@ -1857,32 +1873,36 @@ |
| 1857 | 1873 | |
| 1858 | 1874 | /* |
| 1859 | 1875 | ** Process diff-related command-line options and return an appropriate |
| 1860 | 1876 | ** "diffFlags" integer. |
| 1861 | 1877 | ** |
| 1878 | +** -b|--ignore-space-change Ignore space changes DIFF_IGNORE_WSCHG |
| 1862 | 1879 | ** --brief Show filenames only DIFF_BRIEF |
| 1863 | | -** --context|-c N N lines of context. DIFF_CONTEXT_MASK |
| 1880 | +** -c|--context N N lines of context. DIFF_CONTEXT_MASK |
| 1864 | 1881 | ** --html Format for HTML DIFF_HTML |
| 1865 | 1882 | ** --invert Invert the diff DIFF_INVERT |
| 1866 | | -** --linenum|-n Show line numbers DIFF_LINENO |
| 1883 | +** -n|--linenum Show line numbers DIFF_LINENO |
| 1867 | 1884 | ** --noopt Disable optimization DIFF_NOOPT |
| 1868 | | -** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1869 | 1885 | ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR |
| 1870 | 1886 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 1871 | | -** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1887 | +** -W|--width N N character lines. DIFF_WIDTH_MASK |
| 1872 | 1888 | ** -w|--ignore-all-space Ignore all white space DIFF_IGNORE_ALLWS |
| 1889 | +** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE |
| 1873 | 1890 | ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS |
| 1874 | 1891 | */ |
| 1875 | 1892 | u64 diff_options(void){ |
| 1876 | 1893 | u64 diffFlags = 0; |
| 1877 | 1894 | const char *z; |
| 1878 | 1895 | int f; |
| 1879 | 1896 | if( find_option("ignore-trailing-space","Z",0)!=0 ){ |
| 1880 | 1897 | diffFlags = DIFF_IGNORE_EOLWS; |
| 1881 | 1898 | } |
| 1899 | + if( find_option("ignore-space-change","b",0)!=0 ){ |
| 1900 | + diffFlags = DIFF_IGNORE_WSCHG; /* stronger than DIFF_IGNORE_EOLWS */ |
| 1901 | + } |
| 1882 | 1902 | if( find_option("ignore-all-space","w",0)!=0 ){ |
| 1883 | | - diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */ |
| 1903 | + diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_WSCHG */ |
| 1884 | 1904 | } |
| 1885 | 1905 | if( find_option("strip-trailing-cr",0,0)!=0 ){ |
| 1886 | 1906 | diffFlags |= DIFF_STRIP_EOLCR; |
| 1887 | 1907 | } |
| 1888 | 1908 | if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE; |
| | @@ -2366,10 +2386,11 @@ |
| 2366 | 2386 | ** the file was last modified. The "annotate" command shows line numbers |
| 2367 | 2387 | ** and omits the username. The "blame" and "praise" commands show the user |
| 2368 | 2388 | ** who made each checkin and omits the line number. |
| 2369 | 2389 | ** |
| 2370 | 2390 | ** Options: |
| 2391 | +** -b|--ignore-space-change Ignore white space changes when comparing lines |
| 2371 | 2392 | ** --filevers Show file version numbers rather than check-in versions |
| 2372 | 2393 | ** -l|--log List all versions analyzed |
| 2373 | 2394 | ** -n|--limit N Only look backwards in time by N versions |
| 2374 | 2395 | ** -w|--ignore-all-space Ignore white space when comparing lines |
| 2375 | 2396 | ** -Z|--ignore-trailing-space Ignore whitespace at line end |
| | @@ -2396,14 +2417,17 @@ |
| 2396 | 2417 | zLimit = find_option("limit","n",1); |
| 2397 | 2418 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 2398 | 2419 | iLimit = atoi(zLimit); |
| 2399 | 2420 | showLog = find_option("log","l",0)!=0; |
| 2400 | 2421 | if( find_option("ignore-trailing-space","Z",0)!=0 ){ |
| 2401 | | - flags |= DIFF_IGNORE_EOLWS; |
| 2422 | + flags = DIFF_IGNORE_EOLWS; |
| 2423 | + } |
| 2424 | + if( find_option("ignore-space-change","b",0)!=0 ){ |
| 2425 | + flags = DIFF_IGNORE_WSCHG; /* stronger than DIFF_IGNORE_EOLWS */ |
| 2402 | 2426 | } |
| 2403 | 2427 | if( find_option("ignore-all-space","w",0)!=0 ){ |
| 2404 | | - flags |= DIFF_IGNORE_ALLWS; |
| 2428 | + flags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_WSCHG */ |
| 2405 | 2429 | } |
| 2406 | 2430 | fileVers = find_option("filevers",0,0)!=0; |
| 2407 | 2431 | db_must_be_within_tree(); |
| 2408 | 2432 | if( g.argc<3 ) { |
| 2409 | 2433 | usage("FILENAME"); |
| 2410 | 2434 | |