Fossil

Check-in [554607d3]
Login

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | diff-eolws
Files: files | file ages | folders
SHA1:554607d35b835ba217c0aa59dd9b9aaf8d410903
User & Date: joel 2014-03-03 08:22:30
Context
2014-03-03
09:31
Rename --ignore-space-at-eol to --ignore-eolws|-w, make it work with "fossil stash diff" as well, and make it the default with "fossil diff --tk".

Remark: renaming probably was a bad idea, and "-w" should correspond with git's "--ignore-all-space". This would suggest implementing a "--ignore-space-at-sol" options as well, even though I doubt anyone would use that. check-in: 31d25923 user: jan.nijtmans tags: diff-eolws

08:22
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. check-in: 554607d3 user: joel tags: diff-eolws
06:44
Fix diffs that use the DIFF_IGNORE_EOLWS flag. Add a message for diffs that involve only EOL whitespace changes. check-in: 8f885df2 user: joel tags: diff-eolws
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

1783
1784
1785
1786
1787
1788
1789







1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
      diff_errmsg(pOut, DIFF_CANNOT_COMPUTE_BINARY, diffFlags);
    }
    return 0;
  }

  /* Compute the difference */
  diff_all(&c);







  if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){
    int i, m, n;
    int *a = c.aEdit;
    int mx = c.nEdit;
    for(i=m=n=0; i<mx; i+=3){ m += a[i]; n += a[i+1]+a[i+2]; }
    if( n==0 || n>10000 ){
      fossil_free(c.aFrom);
      fossil_free(c.aTo);
      fossil_free(c.aEdit);
      if( pOut ) {
        diff_errmsg(pOut, n==0 ? DIFF_EOLWS_ONLY : DIFF_TOO_MANY_CHANGES,
                    diffFlags);
      }
      return 0;
    }
  }
  if( (diffFlags & DIFF_NOOPT)==0 ){
    diff_optimize(&c);
  }








>
>
>
>
>
>
>





|



|
<
<
<







1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806



1807
1808
1809
1810
1811
1812
1813
      diff_errmsg(pOut, DIFF_CANNOT_COMPUTE_BINARY, diffFlags);
    }
    return 0;
  }

  /* Compute the difference */
  diff_all(&c);
  if( ignoreEolWs && c.nEdit==6 && c.aEdit[1]==0 && c.aEdit[2]==0 ){
    fossil_free(c.aFrom);
    fossil_free(c.aTo);
    fossil_free(c.aEdit);
    if( pOut ) diff_errmsg(pOut, DIFF_EOLWS_ONLY, diffFlags);
    return 0;
  }
  if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){
    int i, m, n;
    int *a = c.aEdit;
    int mx = c.nEdit;
    for(i=m=n=0; i<mx; i+=3){ m += a[i]; n += a[i+1]+a[i+2]; }
    if( n>10000 ){
      fossil_free(c.aFrom);
      fossil_free(c.aTo);
      fossil_free(c.aEdit);
      if( pOut ) diff_errmsg(pOut, DIFF_TOO_MANY_CHANGES, diffFlags);



      return 0;
    }
  }
  if( (diffFlags & DIFF_NOOPT)==0 ){
    diff_optimize(&c);
  }

Changes to src/diffcmd.c.

1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089

1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
....
1119
1120
1121
1122
1123
1124
1125



1126
1127
1128
1129
1130
1131
1132
** 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
**   --side-by-side|-y   side-by-side diff
**   --tk                Launch a Tcl/Tk GUI for display
**   --to VERSION        select VERSION as target for the diff
**   --unified           unified diff
**   -v|--verbose        output complete text of added or deleted files
**   -W|--width          Width of lines in side-by-side diff
*/
void diff_cmd(void){
  int isGDiff;               /* True for gdiff.  False for normal diff */
  int isInternDiff;          /* True for internal diff */
  int verboseFlag;           /* True if -v or --verbose flag is used */
  const char *zFrom;         /* Source version number */
  const char *zTo;           /* Target version number */
................................................................................
  zBranch = find_option("branch", 0, 1);
  diffFlags = diff_options();
  verboseFlag = find_option("verbose","v",0)!=0;
  if( !verboseFlag ){
    verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
  }
  if( verboseFlag ) diffFlags |= DIFF_VERBOSE;




  if( zBranch ){
    if( zTo || zFrom ){
      fossil_fatal("cannot use --from or --to with --branch");
    }
    zTo = zBranch;
    zFrom = mprintf("root:%s", zBranch);







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







 







>
>
>







1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
....
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
** 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
**   --ignore-space-at-eol  Ignore changes to end-of-line whitespace
**   --internal|-i          use internal diff logic
**   --side-by-side|-y      side-by-side diff
**   --tk                   Launch a Tcl/Tk GUI for display
**   --to VERSION           select VERSION as target for the diff
**   --unified              unified diff
**   -v|--verbose           output complete text of added or deleted files
**   -W|--width             Width of lines in side-by-side diff
*/
void diff_cmd(void){
  int isGDiff;               /* True for gdiff.  False for normal diff */
  int isInternDiff;          /* True for internal diff */
  int verboseFlag;           /* True if -v or --verbose flag is used */
  const char *zFrom;         /* Source version number */
  const char *zTo;           /* Target version number */
................................................................................
  zBranch = find_option("branch", 0, 1);
  diffFlags = diff_options();
  verboseFlag = find_option("verbose","v",0)!=0;
  if( !verboseFlag ){
    verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
  }
  if( verboseFlag ) diffFlags |= DIFF_VERBOSE;
  if( find_option("ignore-space-at-eol",0,0)!=0 ) {
    diffFlags |= DIFF_IGNORE_EOLWS;
  }

  if( zBranch ){
    if( zTo || zFrom ){
      fossil_fatal("cannot use --from or --to with --branch");
    }
    zTo = zBranch;
    zFrom = mprintf("root:%s", zBranch);