Fossil

Check-in [31d25923]
Login

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

Overview
Comment: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.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | diff-eolws
Files: files | file ages | folders
SHA1:31d25923bd1626fc1477ea108c68a6aff1febb76
User & Date: jan.nijtmans 2014-03-03 09:31:56
Original Comment: 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".
Context
2014-03-03
10:15
Rename --ignore-eolws back to --ignore-space-at-eol. Change last parameter of break_into_lines() to hold multiple flags. This opens the way to implement --ignore-all-space" and "--ignore-space-at-sol" as well. check-in: 2dffb0e0 user: jan.nijtmans tags: diff-eolws
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

1836
1837
1838
1839
1840
1841
1842

1843
1844
1845
1846
1847
1848
1849
....
1858
1859
1860
1861
1862
1863
1864

1865
1866
1867
1868
1869
1870
1871
** 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
**   --unified              Unified diff.          ~DIFF_SIDEBYSIDE
**   --width|-W N           N character lines.     DIFF_WIDTH_MASK
*/
u64 diff_options(void){
................................................................................
  }
  if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
    f *= DIFF_CONTEXT_MASK+1;
    if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
    diffFlags |= f;
  }
  if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;

  if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
  if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
  if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
  if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
  return diffFlags;
}








>







 







>







1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
....
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
** 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
**   --ignore-eolws|-w      Ignore eol-whitespaces DIFF_IGNORE_EOLWS
**   --linenum|-n           Show line numbers      DIFF_LINENO
**   --noopt                Disable optimization   DIFF_NOOPT
**   --side-by-side|-y      Side-by-side diff.     DIFF_SIDEBYSIDE
**   --unified              Unified diff.          ~DIFF_SIDEBYSIDE
**   --width|-W N           N character lines.     DIFF_WIDTH_MASK
*/
u64 diff_options(void){
................................................................................
  }
  if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
    f *= DIFF_CONTEXT_MASK+1;
    if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
    diffFlags |= f;
  }
  if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
  if( find_option("ignore-eolws","w",0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
  if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
  if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
  if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
  if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
  return diffFlags;
}

Changes to src/diffcmd.c.

969
970
971
972
973
974
975
976
977
978
979
980
981
982
983

984
985
986
987
988
989
990
....
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
....
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
*/
void diff_tk(const char *zSubCmd, int firstArg){
  int i;
  Blob script;
  char *zTempFile = 0;
  char *zCmd;
  blob_zero(&script);
  blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
               g.nameOfExe, zSubCmd);
  for(i=firstArg; i<g.argc; i++){
    const char *z = g.argv[i];
    if( z[0]=='-' ){
      if( strglob("*-html",z) ) continue;
      if( strglob("*-y",z) ) continue;
      if( strglob("*-i",z) ) continue;

      /* The undocumented --script FILENAME option causes the Tk script to
      ** be written into the FILENAME instead of being run.  This is used
      ** for testing and debugging. */
      if( strglob("*-script",z) && i<g.argc-1 ){
        i++;
        zTempFile = g.argv[i];
        continue;
................................................................................
** 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
................................................................................
  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);
  }







|







>







 







|







 







<
<
<
<







969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
....
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
....
1121
1122
1123
1124
1125
1126
1127




1128
1129
1130
1131
1132
1133
1134
*/
void diff_tk(const char *zSubCmd, int firstArg){
  int i;
  Blob script;
  char *zTempFile = 0;
  char *zCmd;
  blob_zero(&script);
  blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v -w",
               g.nameOfExe, zSubCmd);
  for(i=firstArg; i<g.argc; i++){
    const char *z = g.argv[i];
    if( z[0]=='-' ){
      if( strglob("*-html",z) ) continue;
      if( strglob("*-y",z) ) continue;
      if( strglob("*-i",z) ) continue;
      if( strglob("*-w",z) ) continue;
      /* The undocumented --script FILENAME option causes the Tk script to
      ** be written into the FILENAME instead of being run.  This is used
      ** for testing and debugging. */
      if( strglob("*-script",z) && i<g.argc-1 ){
        i++;
        zTempFile = g.argv[i];
        continue;
................................................................................
** 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-eolws|-w      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
................................................................................
  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);
  }