Fossil

Check-in [c0d1ed92]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Implement -b|--ignore-space-change. Doesn't work right yet (needs better hash function)!
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | strip-trailing-cr
Files: files | file ages | folders
SHA1:c0d1ed927ec219414804aa6c8fd8d8ea24525f2c
User & Date: jan.nijtmans 2014-03-07 14:38:32
Context
2014-03-13
12:55
merge trunk (ongoing) check-in: 2e45fb7b user: jan.nijtmans tags: strip-trailing-cr
2014-03-07
14:38
Implement -b|--ignore-space-change. Doesn't work right yet (needs better hash function)! check-in: c0d1ed92 user: jan.nijtmans tags: strip-trailing-cr
13:11
Combine ANN flags and DIFF flags into a single 64-bit variable, where appropriate. Make DIFF_STRIP_EOLCR a separate flag, as this flag does more than the other whitespace-related flags. Merge trunk. check-in: da205cf4 user: jan.nijtmans tags: strip-trailing-cr
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

27
28
29
30
31
32
33

34
35
36
37
38
39
40
...
173
174
175
176
177
178
179

180
181
182
183
184
185
186













187
188
189
190
191
192
193
...
205
206
207
208
209
210
211

212
213
214
215
216
217
218
219
....
1855
1856
1857
1858
1859
1860
1861

1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872

1873
1874
1875
1876
1877
1878
1879
1880
1881



1882
1883
1884
1885
1886
1887
1888
1889
1890
....
2364
2365
2366
2367
2368
2369
2370

2371
2372
2373
2374
2375
2376
2377
....
2394
2395
2396
2397
2398
2399
2400
2401
2402



2403
2404
2405
2406
2407
2408
2409
2410
2411
/*
** Flag parameters to the text_diff() routine used to control the formatting
** of the diff output.
*/
#define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */
#define DIFF_WIDTH_MASK   ((u64)0x00ff0000) /* side-by-side column width */
#define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */

#define DIFF_IGNORE_ALLWS ((u64)0x03000000) /* Ignore all whitespace */
#define DIFF_SIDEBYSIDE   ((u64)0x04000000) /* Generate a side-by-side diff */
#define DIFF_VERBOSE      ((u64)0x08000000) /* Missing shown as empty files */
#define DIFF_INLINE       ((u64)0x00000000) /* Inline (not side-by-side) diff */
#define DIFF_BRIEF        ((u64)0x10000000) /* Show filenames only */
#define DIFF_HTML         ((u64)0x20000000) /* Render for HTML */
#define DIFF_LINENO       ((u64)0x40000000) /* Show line numbers */
................................................................................
    if( diffFlags & DIFF_STRIP_EOLCR ){
      /* Don't do "extend++" here, because the CR needs to be stripped! */
      if( k>0 && z[k-1]=='\r' ){ k--; }
    }
    if( diffFlags & DIFF_IGNORE_ALLWS ){
      while( k>0 && fossil_isspace(z[k-1]) ){ k--; extent++;}
    }

    if( (diffFlags & DIFF_IGNORE_ALLWS)==DIFF_IGNORE_ALLWS ){
      while( s<k && fossil_isspace(z[s]) ){s++; extent++;}
      for(h=0, x=s; x<k; x++){
        if( fossil_isspace(z[x]) ){
          ++numws;
        }else{
          h = h ^ (h<<2) ^ z[x];













        }
      }
    }else{
      for(h=0, x=0; x<k; x++){
        h = h ^ (h<<2) ^ z[x];
      }
    }
................................................................................
  return a;
}

/*
** Return true if two DLine elements are identical.
*/
static int same_dline(DLine *pA, DLine *pB){

  return pA->h==pB->h && memcmp(pA->z,pB->z,pA->h & LENGTH_MASK)==0;
}

/*
** Return true if the regular expression *pRe matches any of the
** N dlines
*/
static int re_dline_match(
................................................................................
  }
}

/*
** Process diff-related command-line options and return an appropriate
** "diffFlags" integer.
**

**   --brief                    Show filenames only    DIFF_BRIEF
**   --context|-c N             N lines of context.    DIFF_CONTEXT_MASK
**   --html                     Format for HTML        DIFF_HTML
**   --invert                   Invert the diff        DIFF_INVERT
**   --linenum|-n               Show line numbers      DIFF_LINENO
**   --noopt                    Disable optimization   DIFF_NOOPT
**   --side-by-side|-y          Side-by-side diff.     DIFF_SIDEBYSIDE
**   --strip-trailing-cr        Strip trailing CR      DIFF_STRIP_EOLCR
**   --unified                  Unified diff.          ~DIFF_SIDEBYSIDE
**   --width|-W N               N character lines.     DIFF_WIDTH_MASK
**   -w|--ignore-all-space      Ignore all white space DIFF_IGNORE_ALLWS

**   -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
*/
u64 diff_options(void){
  u64 diffFlags = 0;
  const char *z;
  int f;
  if( find_option("ignore-trailing-space","Z",0)!=0 ){
    diffFlags = DIFF_IGNORE_EOLWS;
  }



  if( find_option("ignore-all-space","w",0)!=0 ){
    diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
  }
  if( find_option("strip-trailing-cr",0,0)!=0 ){
    diffFlags |= DIFF_STRIP_EOLCR;
  }
  if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE;
  if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE;
  if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){
................................................................................
**
** Output the text of a file with markings to show when each line of
** the file was last modified.  The "annotate" command shows line numbers
** and omits the username.  The "blame" and "praise" commands show the user
** who made each checkin and omits the line number.
**
** Options:

**   --filevers                  Show file version numbers rather than check-in versions
**   -l|--log                    List all versions analyzed
**   -n|--limit N                Only look backwards in time by N versions
**   -w|--ignore-all-space       Ignore white space when comparing lines
**   -Z|--ignore-trailing-space  Ignore whitespace at line end
**
** See also: info, finfo, timeline
................................................................................

  bBlame = g.argv[1][0]!='a';
  zLimit = find_option("limit","n",1);
  if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1";
  iLimit = atoi(zLimit);
  showLog = find_option("log","l",0)!=0;
  if( find_option("ignore-trailing-space","Z",0)!=0 ){
    flags |= DIFF_IGNORE_EOLWS;
  }



  if( find_option("ignore-all-space","w",0)!=0 ){
    flags |= DIFF_IGNORE_ALLWS;
  }
  fileVers = find_option("filevers",0,0)!=0;
  db_must_be_within_tree();
  if( g.argc<3 ) {
    usage("FILENAME");
  }
  file_tree_name(g.argv[2], &treename, 1);







>







 







>
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
|







 







>

|


|

<


|

>









>
>
>

|







 







>







 







|

>
>
>

|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
....
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884

1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
....
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
....
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
/*
** Flag parameters to the text_diff() routine used to control the formatting
** of the diff output.
*/
#define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */
#define DIFF_WIDTH_MASK   ((u64)0x00ff0000) /* side-by-side column width */
#define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */
#define DIFF_IGNORE_WSCHG ((u64)0x02000000) /* Ignore whitespace changes */
#define DIFF_IGNORE_ALLWS ((u64)0x03000000) /* Ignore all whitespace */
#define DIFF_SIDEBYSIDE   ((u64)0x04000000) /* Generate a side-by-side diff */
#define DIFF_VERBOSE      ((u64)0x08000000) /* Missing shown as empty files */
#define DIFF_INLINE       ((u64)0x00000000) /* Inline (not side-by-side) diff */
#define DIFF_BRIEF        ((u64)0x10000000) /* Show filenames only */
#define DIFF_HTML         ((u64)0x20000000) /* Render for HTML */
#define DIFF_LINENO       ((u64)0x40000000) /* Show line numbers */
................................................................................
    if( diffFlags & DIFF_STRIP_EOLCR ){
      /* Don't do "extend++" here, because the CR needs to be stripped! */
      if( k>0 && z[k-1]=='\r' ){ k--; }
    }
    if( diffFlags & DIFF_IGNORE_ALLWS ){
      while( k>0 && fossil_isspace(z[k-1]) ){ k--; extent++;}
    }
    if( diffFlags & DIFF_IGNORE_WSCHG ){
      if( (diffFlags & DIFF_IGNORE_ALLWS)==DIFF_IGNORE_ALLWS ){
        while( s<k && fossil_isspace(z[s]) ){s++; extent++;}
        for(h=0, x=s; x<k; x++){
          if( fossil_isspace(z[x]) ){
            ++numws;
          }else{
            h = h ^ (h<<2) ^ z[x];
          }
        }
      }else{
        for(h=0, x=0; x<k; x++){
          if( fossil_isspace(z[x]) ){
            if( x>0 && !fossil_isspace(z[x-1]) ){
              ++numws;
            }else{
              h = h ^ (h<<2) ^ ' ';
            }
          }else{
            h = h ^ (h<<2) ^ z[x];
          }
        }
      }
    }else{
      for(h=0, x=0; x<k; x++){
        h = h ^ (h<<2) ^ z[x];
      }
    }
................................................................................
  return a;
}

/*
** Return true if two DLine elements are identical.
*/
static int same_dline(DLine *pA, DLine *pB){
  return pA->h==pB->h; // TODO: not quite right, need better hash function.
  //return pA->h==pB->h && memcmp(pA->z,pB->z,pA->h & LENGTH_MASK)==0;
}

/*
** Return true if the regular expression *pRe matches any of the
** N dlines
*/
static int re_dline_match(
................................................................................
  }
}

/*
** Process diff-related command-line options and return an appropriate
** "diffFlags" integer.
**
**   -b|--ignore-space-change   Ignore space changes   DIFF_IGNORE_WSCHG
**   --brief                    Show filenames only    DIFF_BRIEF
**   -c|--context N             N lines of context.    DIFF_CONTEXT_MASK
**   --html                     Format for HTML        DIFF_HTML
**   --invert                   Invert the diff        DIFF_INVERT
**   -n|--linenum               Show line numbers      DIFF_LINENO
**   --noopt                    Disable optimization   DIFF_NOOPT

**   --strip-trailing-cr        Strip trailing CR      DIFF_STRIP_EOLCR
**   --unified                  Unified diff.          ~DIFF_SIDEBYSIDE
**   -W|--width N               N character lines.     DIFF_WIDTH_MASK
**   -w|--ignore-all-space      Ignore all white space DIFF_IGNORE_ALLWS
**   -y|--side-by-side          Side-by-side diff.     DIFF_SIDEBYSIDE
**   -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
*/
u64 diff_options(void){
  u64 diffFlags = 0;
  const char *z;
  int f;
  if( find_option("ignore-trailing-space","Z",0)!=0 ){
    diffFlags = DIFF_IGNORE_EOLWS;
  }
  if( find_option("ignore-space-change","b",0)!=0 ){
    diffFlags = DIFF_IGNORE_WSCHG; /* stronger than DIFF_IGNORE_EOLWS */
  }
  if( find_option("ignore-all-space","w",0)!=0 ){
    diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_WSCHG */
  }
  if( find_option("strip-trailing-cr",0,0)!=0 ){
    diffFlags |= DIFF_STRIP_EOLCR;
  }
  if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE;
  if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE;
  if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){
................................................................................
**
** Output the text of a file with markings to show when each line of
** the file was last modified.  The "annotate" command shows line numbers
** and omits the username.  The "blame" and "praise" commands show the user
** who made each checkin and omits the line number.
**
** Options:
**   -b|--ignore-space-change    Ignore white space changes when comparing lines
**   --filevers                  Show file version numbers rather than check-in versions
**   -l|--log                    List all versions analyzed
**   -n|--limit N                Only look backwards in time by N versions
**   -w|--ignore-all-space       Ignore white space when comparing lines
**   -Z|--ignore-trailing-space  Ignore whitespace at line end
**
** See also: info, finfo, timeline
................................................................................

  bBlame = g.argv[1][0]!='a';
  zLimit = find_option("limit","n",1);
  if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1";
  iLimit = atoi(zLimit);
  showLog = find_option("log","l",0)!=0;
  if( find_option("ignore-trailing-space","Z",0)!=0 ){
    flags = DIFF_IGNORE_EOLWS;
  }
  if( find_option("ignore-space-change","b",0)!=0 ){
    flags = DIFF_IGNORE_WSCHG; /* stronger than DIFF_IGNORE_EOLWS */
  }
  if( find_option("ignore-all-space","w",0)!=0 ){
    flags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_WSCHG */
  }
  fileVers = find_option("filevers",0,0)!=0;
  db_must_be_within_tree();
  if( g.argc<3 ) {
    usage("FILENAME");
  }
  file_tree_name(g.argv[2], &treename, 1);

Changes to src/diffcmd.c.

1087
1088
1089
1090
1091
1092
1093

1094
1095
1096
1097
1098
1099
1100
** when using an external diff program.
**
** The "--binary" option causes files matching the glob PATTERN to be treated
** as binary when considering if they should be used with external diff program.
** This option overrides the "binary-glob" setting.
**
** Options:

**   --binary PATTERN           Treat files that match the glob PATTERN as binary
**   --branch BRANCH            Show diff of all changes on BRANCH
**   --brief                    Show filenames only
**   --context|-c N             Use N lines of context
**   --diff-binary BOOL         Include binary files when using external commands
**   --from|-r VERSION          select VERSION as source for the diff
**   --internal|-i              use internal diff logic







>







1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
** when using an external diff program.
**
** The "--binary" option causes files matching the glob PATTERN to be treated
** as binary when considering if they should be used with external diff program.
** This option overrides the "binary-glob" setting.
**
** Options:
**   -b|--ignore-space-change   Ignore white space changes when comparing lines
**   --binary PATTERN           Treat files that match the glob PATTERN as binary
**   --branch BRANCH            Show diff of all changes on BRANCH
**   --brief                    Show filenames only
**   --context|-c N             Use N lines of context
**   --diff-binary BOOL         Include binary files when using external commands
**   --from|-r VERSION          select VERSION as source for the diff
**   --internal|-i              use internal diff logic

Changes to www/changes.wiki.

9
10
11
12
13
14
15

16
17
18
19
20
21
22
23
24
25
26
  *  The [/reports] page now requires Read ("o") permissions. The "byweek"
     report now properly propagates the selected year through the event type
     filter links.
  *  The [/help/info | info command] now shows leaf status of the checkout.
  *  Add support for tunneling https through a http proxy (Ticket [e854101c4f]).
  *  Add option --empty to the "[/help?cmd=open | fossil open]" command.
  *  Enhanced [/help?cmd=/fileage|the fileage page] to support a glob parameter.

  *  Add -w|--ignore-all-space and -Z|--ignore-trailing-space options to
     [/help?cmd=annotate|fossil annotate], [/help?cmd=blame|fossil blame],
     [/help?cmd=diff|fossil (g)diff], [/help?cmd=stash|fossil stash diff].
  *  Add --strip-trailing-cr options to [/help?cmd=diff|fossil (g)diff] and
     [/help?cmd=stash|fossil stash diff].
  *  Add button "Ignore Whitespace" to /annotate, /blame, /ci, /fdiff
     and /vdiff UI pages.

<h2>Changes For Version 1.28 (2014-01-27)</h2>
  *  Enhance [/help?cmd=/reports | /reports] to support event type filtering.
  *  When cloning a repository, the user name passed via the URL (if any)







>
|
|
|
|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  *  The [/reports] page now requires Read ("o") permissions. The "byweek"
     report now properly propagates the selected year through the event type
     filter links.
  *  The [/help/info | info command] now shows leaf status of the checkout.
  *  Add support for tunneling https through a http proxy (Ticket [e854101c4f]).
  *  Add option --empty to the "[/help?cmd=open | fossil open]" command.
  *  Enhanced [/help?cmd=/fileage|the fileage page] to support a glob parameter.
  *  Add -w|--ignore-all-space, -b|--ignore-space-change and
     -Z|--ignore-trailing-space options to [/help?cmd=annotate|fossil annotate],
     [/help?cmd=blame|fossil blame], [/help?cmd=diff|fossil (g)diff],
     [/help?cmd=stash|fossil stash diff].
  *  Add --strip-trailing-cr option to [/help?cmd=diff|fossil (g)diff] and
     [/help?cmd=stash|fossil stash diff].
  *  Add button "Ignore Whitespace" to /annotate, /blame, /ci, /fdiff
     and /vdiff UI pages.

<h2>Changes For Version 1.28 (2014-01-27)</h2>
  *  Enhance [/help?cmd=/reports | /reports] to support event type filtering.
  *  When cloning a repository, the user name passed via the URL (if any)