Fossil SCM

Incremental step in integrating DiffConfig.

drh 2021-09-06 18:35 diff-config
Commit f7c8416fcd5c7db842966f2d4c092e4b55f5b998a6e1425e07b22b8b0c1d8c25
4 files changed +26 -14 +9 -10 +13 -14 +16 -18
+26 -14
--- src/diff.c
+++ src/diff.c
@@ -72,11 +72,26 @@
7272
*/
7373
#define LENGTH_MASK_SZ 15
7474
#define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1)
7575
7676
/*
77
-** Configuration options for a diff operation
77
+** An instance of this object describes the formatting and processing
78
+** details desired of a "diff" operation.
79
+**
80
+** Conceptually, this object is as an encoding of the command-line options
81
+** for the "fossil diff" command. That is not a precise description, though,
82
+** because not all diff operations are started from the command-line. But
83
+** the idea is sound.
84
+**
85
+** Information encoded by this object includes but is not limited to:
86
+**
87
+** * The desired output format (unified vs. side-by-side,
88
+** TCL, JSON, HTML vs. plain-text).
89
+**
90
+** * Number of lines of context surrounding each difference block
91
+**
92
+** * Width of output columns for text side-by-side diffop
7893
*/
7994
struct DiffConfig {
8095
u64 diffFlags; /* Legacy diff flags */
8196
};
8297
@@ -2725,10 +2740,12 @@
27252740
return c.aEdit;
27262741
}
27272742
}
27282743
27292744
/*
2745
+** Initialize the DiffConfig object using command-line options.
2746
+**
27302747
** Process diff-related command-line options and return an appropriate
27312748
** "diffFlags" integer.
27322749
**
27332750
** --brief Show filenames only DIFF_BRIEF
27342751
** -c|--context N N lines of context. DIFF_CONTEXT_MASK
@@ -2742,17 +2759,16 @@
27422759
** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
27432760
** -W|--width N N character lines. DIFF_WIDTH_MASK
27442761
** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
27452762
** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
27462763
*/
2747
-u64 diff_options(DiffConfig *pCfg){
2764
+void diff_options(DiffConfig *pCfg, int isGDiff){
27482765
u64 diffFlags = 0;
27492766
const char *z;
27502767
int f;
2751
- if( pCfg ){
2752
- memset(pCfg, 0, sizeof(*pCfg));
2753
- }
2768
+
2769
+ memset(pCfg, 0, sizeof(*pCfg));
27542770
if( find_option("ignore-trailing-space","Z",0)!=0 ){
27552771
diffFlags = DIFF_IGNORE_EOLWS;
27562772
}
27572773
if( find_option("ignore-all-space","w",0)!=0 ){
27582774
diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
@@ -2799,14 +2815,11 @@
27992815
28002816
/* Undocumented and unsupported flags used for development
28012817
** debugging and analysis: */
28022818
if( find_option("debug",0,0)!=0 ) diffFlags |= DIFF_DEBUG;
28032819
if( find_option("raw",0,0)!=0 ) diffFlags |= DIFF_RAW;
2804
- if( pCfg ){
2805
- pCfg->diffFlags = diffFlags;
2806
- }
2807
- return diffFlags;
2820
+ pCfg->diffFlags = diffFlags;
28082821
}
28092822
28102823
/*
28112824
** COMMAND: test-diff
28122825
** COMMAND: xdiff
@@ -2826,11 +2839,10 @@
28262839
** This command used to be called "test-diff". The older "test-diff" spelling
28272840
** still works, for compatibility.
28282841
*/
28292842
void test_diff_cmd(void){
28302843
Blob a, b, out;
2831
- u64 diffFlag;
28322844
const char *zRe; /* Regex filter for diff output */
28332845
ReCompiled *pRe = 0; /* Regex filter for diff output */
28342846
DiffConfig DCfg;
28352847
28362848
if( find_option("tk",0,0)!=0 ){
@@ -2842,21 +2854,21 @@
28422854
zRe = find_option("regexp","e",1);
28432855
if( zRe ){
28442856
const char *zErr = re_compile(&pRe, zRe, 0);
28452857
if( zErr ) fossil_fatal("regex error: %s", zErr);
28462858
}
2847
- diffFlag = diff_options(&DCfg);
2859
+ diff_options(&DCfg, 0);
28482860
verify_all_options();
28492861
if( g.argc!=4 ) usage("FILE1 FILE2");
28502862
blob_zero(&out);
2851
- diff_begin(diffFlag);
2852
- diff_print_filenames(g.argv[2], g.argv[3], diffFlag, &out);
2863
+ diff_begin(DCfg.diffFlags);
2864
+ diff_print_filenames(g.argv[2], g.argv[3], DCfg.diffFlags, &out);
28532865
blob_read_from_file(&a, g.argv[2], ExtFILE);
28542866
blob_read_from_file(&b, g.argv[3], ExtFILE);
28552867
text_diff(&a, &b, &out, pRe, &DCfg);
28562868
blob_write_to_file(&out, "-");
2857
- diff_end(diffFlag, 0);
2869
+ diff_end(DCfg.diffFlags, 0);
28582870
re_free(pRe);
28592871
}
28602872
28612873
/**************************************************************************
28622874
** The basic difference engine is above. What follows is the annotation
28632875
--- src/diff.c
+++ src/diff.c
@@ -72,11 +72,26 @@
72 */
73 #define LENGTH_MASK_SZ 15
74 #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1)
75
76 /*
77 ** Configuration options for a diff operation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78 */
79 struct DiffConfig {
80 u64 diffFlags; /* Legacy diff flags */
81 };
82
@@ -2725,10 +2740,12 @@
2725 return c.aEdit;
2726 }
2727 }
2728
2729 /*
 
 
2730 ** Process diff-related command-line options and return an appropriate
2731 ** "diffFlags" integer.
2732 **
2733 ** --brief Show filenames only DIFF_BRIEF
2734 ** -c|--context N N lines of context. DIFF_CONTEXT_MASK
@@ -2742,17 +2759,16 @@
2742 ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
2743 ** -W|--width N N character lines. DIFF_WIDTH_MASK
2744 ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
2745 ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
2746 */
2747 u64 diff_options(DiffConfig *pCfg){
2748 u64 diffFlags = 0;
2749 const char *z;
2750 int f;
2751 if( pCfg ){
2752 memset(pCfg, 0, sizeof(*pCfg));
2753 }
2754 if( find_option("ignore-trailing-space","Z",0)!=0 ){
2755 diffFlags = DIFF_IGNORE_EOLWS;
2756 }
2757 if( find_option("ignore-all-space","w",0)!=0 ){
2758 diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
@@ -2799,14 +2815,11 @@
2799
2800 /* Undocumented and unsupported flags used for development
2801 ** debugging and analysis: */
2802 if( find_option("debug",0,0)!=0 ) diffFlags |= DIFF_DEBUG;
2803 if( find_option("raw",0,0)!=0 ) diffFlags |= DIFF_RAW;
2804 if( pCfg ){
2805 pCfg->diffFlags = diffFlags;
2806 }
2807 return diffFlags;
2808 }
2809
2810 /*
2811 ** COMMAND: test-diff
2812 ** COMMAND: xdiff
@@ -2826,11 +2839,10 @@
2826 ** This command used to be called "test-diff". The older "test-diff" spelling
2827 ** still works, for compatibility.
2828 */
2829 void test_diff_cmd(void){
2830 Blob a, b, out;
2831 u64 diffFlag;
2832 const char *zRe; /* Regex filter for diff output */
2833 ReCompiled *pRe = 0; /* Regex filter for diff output */
2834 DiffConfig DCfg;
2835
2836 if( find_option("tk",0,0)!=0 ){
@@ -2842,21 +2854,21 @@
2842 zRe = find_option("regexp","e",1);
2843 if( zRe ){
2844 const char *zErr = re_compile(&pRe, zRe, 0);
2845 if( zErr ) fossil_fatal("regex error: %s", zErr);
2846 }
2847 diffFlag = diff_options(&DCfg);
2848 verify_all_options();
2849 if( g.argc!=4 ) usage("FILE1 FILE2");
2850 blob_zero(&out);
2851 diff_begin(diffFlag);
2852 diff_print_filenames(g.argv[2], g.argv[3], diffFlag, &out);
2853 blob_read_from_file(&a, g.argv[2], ExtFILE);
2854 blob_read_from_file(&b, g.argv[3], ExtFILE);
2855 text_diff(&a, &b, &out, pRe, &DCfg);
2856 blob_write_to_file(&out, "-");
2857 diff_end(diffFlag, 0);
2858 re_free(pRe);
2859 }
2860
2861 /**************************************************************************
2862 ** The basic difference engine is above. What follows is the annotation
2863
--- src/diff.c
+++ src/diff.c
@@ -72,11 +72,26 @@
72 */
73 #define LENGTH_MASK_SZ 15
74 #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1)
75
76 /*
77 ** An instance of this object describes the formatting and processing
78 ** details desired of a "diff" operation.
79 **
80 ** Conceptually, this object is as an encoding of the command-line options
81 ** for the "fossil diff" command. That is not a precise description, though,
82 ** because not all diff operations are started from the command-line. But
83 ** the idea is sound.
84 **
85 ** Information encoded by this object includes but is not limited to:
86 **
87 ** * The desired output format (unified vs. side-by-side,
88 ** TCL, JSON, HTML vs. plain-text).
89 **
90 ** * Number of lines of context surrounding each difference block
91 **
92 ** * Width of output columns for text side-by-side diffop
93 */
94 struct DiffConfig {
95 u64 diffFlags; /* Legacy diff flags */
96 };
97
@@ -2725,10 +2740,12 @@
2740 return c.aEdit;
2741 }
2742 }
2743
2744 /*
2745 ** Initialize the DiffConfig object using command-line options.
2746 **
2747 ** Process diff-related command-line options and return an appropriate
2748 ** "diffFlags" integer.
2749 **
2750 ** --brief Show filenames only DIFF_BRIEF
2751 ** -c|--context N N lines of context. DIFF_CONTEXT_MASK
@@ -2742,17 +2759,16 @@
2759 ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
2760 ** -W|--width N N character lines. DIFF_WIDTH_MASK
2761 ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
2762 ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
2763 */
2764 void diff_options(DiffConfig *pCfg, int isGDiff){
2765 u64 diffFlags = 0;
2766 const char *z;
2767 int f;
2768
2769 memset(pCfg, 0, sizeof(*pCfg));
 
2770 if( find_option("ignore-trailing-space","Z",0)!=0 ){
2771 diffFlags = DIFF_IGNORE_EOLWS;
2772 }
2773 if( find_option("ignore-all-space","w",0)!=0 ){
2774 diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
@@ -2799,14 +2815,11 @@
2815
2816 /* Undocumented and unsupported flags used for development
2817 ** debugging and analysis: */
2818 if( find_option("debug",0,0)!=0 ) diffFlags |= DIFF_DEBUG;
2819 if( find_option("raw",0,0)!=0 ) diffFlags |= DIFF_RAW;
2820 pCfg->diffFlags = diffFlags;
 
 
 
2821 }
2822
2823 /*
2824 ** COMMAND: test-diff
2825 ** COMMAND: xdiff
@@ -2826,11 +2839,10 @@
2839 ** This command used to be called "test-diff". The older "test-diff" spelling
2840 ** still works, for compatibility.
2841 */
2842 void test_diff_cmd(void){
2843 Blob a, b, out;
 
2844 const char *zRe; /* Regex filter for diff output */
2845 ReCompiled *pRe = 0; /* Regex filter for diff output */
2846 DiffConfig DCfg;
2847
2848 if( find_option("tk",0,0)!=0 ){
@@ -2842,21 +2854,21 @@
2854 zRe = find_option("regexp","e",1);
2855 if( zRe ){
2856 const char *zErr = re_compile(&pRe, zRe, 0);
2857 if( zErr ) fossil_fatal("regex error: %s", zErr);
2858 }
2859 diff_options(&DCfg, 0);
2860 verify_all_options();
2861 if( g.argc!=4 ) usage("FILE1 FILE2");
2862 blob_zero(&out);
2863 diff_begin(DCfg.diffFlags);
2864 diff_print_filenames(g.argv[2], g.argv[3], DCfg.diffFlags, &out);
2865 blob_read_from_file(&a, g.argv[2], ExtFILE);
2866 blob_read_from_file(&b, g.argv[3], ExtFILE);
2867 text_diff(&a, &b, &out, pRe, &DCfg);
2868 blob_write_to_file(&out, "-");
2869 diff_end(DCfg.diffFlags, 0);
2870 re_free(pRe);
2871 }
2872
2873 /**************************************************************************
2874 ** The basic difference engine is above. What follows is the annotation
2875
+9 -10
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1112,11 +1112,10 @@
11121112
const char *zBranch; /* Branch to diff */
11131113
const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
11141114
const char *zBinGlob = 0; /* Treat file names matching this as binary */
11151115
int fIncludeBinary = 0; /* Include binary files for external diff */
11161116
int againstUndo = 0; /* Diff against files in the undo buffer */
1117
- u64 diffFlags = 0; /* Flags to control the DIFF */
11181117
FileDirList *pFileDir = 0; /* Restrict the diff to these files */
11191118
DiffConfig DCfg; /* Diff configuration object */
11201119
11211120
if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
11221121
diff_tk("diff", 2);
@@ -1127,16 +1126,16 @@
11271126
zFrom = find_option("from", "r", 1);
11281127
zTo = find_option("to", 0, 1);
11291128
zCheckin = find_option("checkin", 0, 1);
11301129
zBranch = find_option("branch", 0, 1);
11311130
againstUndo = find_option("undo",0,0)!=0;
1132
- diffFlags = diff_options(&DCfg);
1131
+ diff_options(&DCfg, isGDiff);
11331132
verboseFlag = find_option("verbose","v",0)!=0;
11341133
if( !verboseFlag ){
11351134
verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
11361135
}
1137
- if( verboseFlag ) diffFlags |= DIFF_VERBOSE;
1136
+ if( verboseFlag ) DCfg.diffFlags |= DIFF_VERBOSE;
11381137
if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
11391138
fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
11401139
" or --branch");
11411140
}
11421141
if( zBranch ){
@@ -1156,11 +1155,11 @@
11561155
fossil_fatal("must use --from if --to is present");
11571156
}else{
11581157
db_find_and_open_repository(0, 0);
11591158
}
11601159
if( !isInternDiff
1161
- && (diffFlags & DIFF_HTML)==0 /* External diff can't generate HTML */
1160
+ && (DCfg.diffFlags & DIFF_HTML)==0 /* External diff can't generate HTML */
11621161
){
11631162
zDiffCmd = find_option("command", 0, 1);
11641163
if( zDiffCmd==0 ) zDiffCmd = diff_command_external(isGDiff);
11651164
}
11661165
zBinGlob = diff_get_binary_glob();
@@ -1194,24 +1193,24 @@
11941193
ridTo);
11951194
if( zFrom==0 ){
11961195
fossil_fatal("check-in %s has no parent", zTo);
11971196
}
11981197
}
1199
- diff_begin(diffFlags);
1198
+ diff_begin(DCfg.diffFlags);
12001199
if( againstUndo ){
12011200
if( db_lget_int("undo_available",0)==0 ){
12021201
fossil_print("No undo or redo is available\n");
12031202
return;
12041203
}
12051204
diff_against_undo(zDiffCmd, zBinGlob, fIncludeBinary,
1206
- diffFlags, pFileDir);
1205
+ DCfg.diffFlags, pFileDir);
12071206
}else if( zTo==0 ){
12081207
diff_against_disk(zFrom, zDiffCmd, zBinGlob, fIncludeBinary,
1209
- diffFlags, pFileDir, 0);
1208
+ DCfg.diffFlags, pFileDir, 0);
12101209
}else{
12111210
diff_two_versions(zFrom, zTo, zDiffCmd, zBinGlob, fIncludeBinary,
1212
- diffFlags, pFileDir);
1211
+ DCfg.diffFlags, pFileDir);
12131212
}
12141213
if( pFileDir ){
12151214
int i;
12161215
for(i=0; pFileDir[i].zName; i++){
12171216
if( pFileDir[i].nUsed==0
@@ -1222,12 +1221,12 @@
12221221
}
12231222
fossil_free(pFileDir[i].zName);
12241223
}
12251224
fossil_free(pFileDir);
12261225
}
1227
- diff_end(diffFlags, 0);
1228
- if ( diffFlags & DIFF_NUMSTAT ){
1226
+ diff_end(DCfg.diffFlags, 0);
1227
+ if ( DCfg.diffFlags & DIFF_NUMSTAT ){
12291228
fossil_print("%10d %10d TOTAL over %d changed files\n",
12301229
g.diffCnt[1], g.diffCnt[2], g.diffCnt[0]);
12311230
}
12321231
}
12331232
12341233
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1112,11 +1112,10 @@
1112 const char *zBranch; /* Branch to diff */
1113 const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
1114 const char *zBinGlob = 0; /* Treat file names matching this as binary */
1115 int fIncludeBinary = 0; /* Include binary files for external diff */
1116 int againstUndo = 0; /* Diff against files in the undo buffer */
1117 u64 diffFlags = 0; /* Flags to control the DIFF */
1118 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1119 DiffConfig DCfg; /* Diff configuration object */
1120
1121 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1122 diff_tk("diff", 2);
@@ -1127,16 +1126,16 @@
1127 zFrom = find_option("from", "r", 1);
1128 zTo = find_option("to", 0, 1);
1129 zCheckin = find_option("checkin", 0, 1);
1130 zBranch = find_option("branch", 0, 1);
1131 againstUndo = find_option("undo",0,0)!=0;
1132 diffFlags = diff_options(&DCfg);
1133 verboseFlag = find_option("verbose","v",0)!=0;
1134 if( !verboseFlag ){
1135 verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
1136 }
1137 if( verboseFlag ) diffFlags |= DIFF_VERBOSE;
1138 if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1139 fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
1140 " or --branch");
1141 }
1142 if( zBranch ){
@@ -1156,11 +1155,11 @@
1156 fossil_fatal("must use --from if --to is present");
1157 }else{
1158 db_find_and_open_repository(0, 0);
1159 }
1160 if( !isInternDiff
1161 && (diffFlags & DIFF_HTML)==0 /* External diff can't generate HTML */
1162 ){
1163 zDiffCmd = find_option("command", 0, 1);
1164 if( zDiffCmd==0 ) zDiffCmd = diff_command_external(isGDiff);
1165 }
1166 zBinGlob = diff_get_binary_glob();
@@ -1194,24 +1193,24 @@
1194 ridTo);
1195 if( zFrom==0 ){
1196 fossil_fatal("check-in %s has no parent", zTo);
1197 }
1198 }
1199 diff_begin(diffFlags);
1200 if( againstUndo ){
1201 if( db_lget_int("undo_available",0)==0 ){
1202 fossil_print("No undo or redo is available\n");
1203 return;
1204 }
1205 diff_against_undo(zDiffCmd, zBinGlob, fIncludeBinary,
1206 diffFlags, pFileDir);
1207 }else if( zTo==0 ){
1208 diff_against_disk(zFrom, zDiffCmd, zBinGlob, fIncludeBinary,
1209 diffFlags, pFileDir, 0);
1210 }else{
1211 diff_two_versions(zFrom, zTo, zDiffCmd, zBinGlob, fIncludeBinary,
1212 diffFlags, pFileDir);
1213 }
1214 if( pFileDir ){
1215 int i;
1216 for(i=0; pFileDir[i].zName; i++){
1217 if( pFileDir[i].nUsed==0
@@ -1222,12 +1221,12 @@
1222 }
1223 fossil_free(pFileDir[i].zName);
1224 }
1225 fossil_free(pFileDir);
1226 }
1227 diff_end(diffFlags, 0);
1228 if ( diffFlags & DIFF_NUMSTAT ){
1229 fossil_print("%10d %10d TOTAL over %d changed files\n",
1230 g.diffCnt[1], g.diffCnt[2], g.diffCnt[0]);
1231 }
1232 }
1233
1234
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1112,11 +1112,10 @@
1112 const char *zBranch; /* Branch to diff */
1113 const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
1114 const char *zBinGlob = 0; /* Treat file names matching this as binary */
1115 int fIncludeBinary = 0; /* Include binary files for external diff */
1116 int againstUndo = 0; /* Diff against files in the undo buffer */
 
1117 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1118 DiffConfig DCfg; /* Diff configuration object */
1119
1120 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1121 diff_tk("diff", 2);
@@ -1127,16 +1126,16 @@
1126 zFrom = find_option("from", "r", 1);
1127 zTo = find_option("to", 0, 1);
1128 zCheckin = find_option("checkin", 0, 1);
1129 zBranch = find_option("branch", 0, 1);
1130 againstUndo = find_option("undo",0,0)!=0;
1131 diff_options(&DCfg, isGDiff);
1132 verboseFlag = find_option("verbose","v",0)!=0;
1133 if( !verboseFlag ){
1134 verboseFlag = find_option("new-file","N",0)!=0; /* deprecated */
1135 }
1136 if( verboseFlag ) DCfg.diffFlags |= DIFF_VERBOSE;
1137 if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1138 fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
1139 " or --branch");
1140 }
1141 if( zBranch ){
@@ -1156,11 +1155,11 @@
1155 fossil_fatal("must use --from if --to is present");
1156 }else{
1157 db_find_and_open_repository(0, 0);
1158 }
1159 if( !isInternDiff
1160 && (DCfg.diffFlags & DIFF_HTML)==0 /* External diff can't generate HTML */
1161 ){
1162 zDiffCmd = find_option("command", 0, 1);
1163 if( zDiffCmd==0 ) zDiffCmd = diff_command_external(isGDiff);
1164 }
1165 zBinGlob = diff_get_binary_glob();
@@ -1194,24 +1193,24 @@
1193 ridTo);
1194 if( zFrom==0 ){
1195 fossil_fatal("check-in %s has no parent", zTo);
1196 }
1197 }
1198 diff_begin(DCfg.diffFlags);
1199 if( againstUndo ){
1200 if( db_lget_int("undo_available",0)==0 ){
1201 fossil_print("No undo or redo is available\n");
1202 return;
1203 }
1204 diff_against_undo(zDiffCmd, zBinGlob, fIncludeBinary,
1205 DCfg.diffFlags, pFileDir);
1206 }else if( zTo==0 ){
1207 diff_against_disk(zFrom, zDiffCmd, zBinGlob, fIncludeBinary,
1208 DCfg.diffFlags, pFileDir, 0);
1209 }else{
1210 diff_two_versions(zFrom, zTo, zDiffCmd, zBinGlob, fIncludeBinary,
1211 DCfg.diffFlags, pFileDir);
1212 }
1213 if( pFileDir ){
1214 int i;
1215 for(i=0; pFileDir[i].zName; i++){
1216 if( pFileDir[i].nUsed==0
@@ -1222,12 +1221,12 @@
1221 }
1222 fossil_free(pFileDir[i].zName);
1223 }
1224 fossil_free(pFileDir);
1225 }
1226 diff_end(DCfg.diffFlags, 0);
1227 if ( DCfg.diffFlags & DIFF_NUMSTAT ){
1228 fossil_print("%10d %10d TOTAL over %d changed files\n",
1229 g.diffCnt[1], g.diffCnt[2], g.diffCnt[0]);
1230 }
1231 }
1232
1233
+13 -14
--- src/patch.c
+++ src/patch.c
@@ -720,15 +720,15 @@
720720
static void patch_diff(
721721
unsigned mFlags, /* Patch flags. only -f is allowed */
722722
const char *zDiffCmd, /* Command used for diffing */
723723
const char *zBinGlob, /* GLOB pattern to determine binary files */
724724
int fIncludeBinary, /* Do diffs against binary files */
725
- u64 diffFlags /* Other diff flags */
725
+ DiffConfig *pCfg /* Diff options */
726726
){
727727
int nErr = 0;
728728
Stmt q;
729
- int bWebpage = (diffFlags & DIFF_WEBPAGE)!=0;
729
+ int bWebpage = (pCfg->diffFlags & DIFF_WEBPAGE)!=0;
730730
Blob empty;
731731
blob_zero(&empty);
732732
733733
if( (mFlags & PATCH_FORCE)==0 ){
734734
/* Check to ensure that the patch is against the repository that
@@ -764,11 +764,11 @@
764764
"in the %s repository", zBaseline, g.zRepositoryName);
765765
}
766766
}
767767
}
768768
769
- diff_begin(diffFlags);
769
+ diff_begin(pCfg->diffFlags);
770770
db_prepare(&q,
771771
"SELECT"
772772
" (SELECT blob.rid FROM blob WHERE blob.uuid=chng.hash),"
773773
" pathname," /* 1: new pathname */
774774
" origname," /* 2: original pathname. Null if not renamed */
@@ -804,25 +804,25 @@
804804
zName = db_column_text(&q, 1);
805805
rid = db_column_int(&q, 0);
806806
807807
if( db_column_type(&q,3)==SQLITE_NULL ){
808808
if( !bWebpage ) fossil_print("DELETE %s\n", zName);
809
- diff_print_index(zName, diffFlags, 0);
809
+ diff_print_index(zName, pCfg->diffFlags, 0);
810810
isBin2 = 0;
811811
content_get(rid, &a);
812812
isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
813813
diff_file_mem(&a, &empty, isBin1, isBin2, zName, zDiffCmd,
814
- zBinGlob, fIncludeBinary, diffFlags);
814
+ zBinGlob, fIncludeBinary, pCfg->diffFlags);
815815
}else if( rid==0 ){
816816
db_ephemeral_blob(&q, 3, &a);
817817
blob_uncompress(&a, &a);
818818
if( !bWebpage ) fossil_print("ADDED %s\n", zName);
819
- diff_print_index(zName, diffFlags, 0);
819
+ diff_print_index(zName, pCfg->diffFlags, 0);
820820
isBin1 = 0;
821821
isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
822822
diff_file_mem(&empty, &a, isBin1, isBin2, zName, zDiffCmd,
823
- zBinGlob, fIncludeBinary, diffFlags);
823
+ zBinGlob, fIncludeBinary, pCfg->diffFlags);
824824
blob_reset(&a);
825825
}else if( db_column_bytes(&q, 3)>0 ){
826826
Blob delta;
827827
db_ephemeral_blob(&q, 3, &delta);
828828
blob_uncompress(&delta, &delta);
@@ -829,18 +829,18 @@
829829
content_get(rid, &a);
830830
blob_delta_apply(&a, &delta, &b);
831831
isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
832832
isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
833833
diff_file_mem(&a, &b, isBin1, isBin2, zName,
834
- zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
834
+ zDiffCmd, zBinGlob, fIncludeBinary, pCfg->diffFlags);
835835
blob_reset(&a);
836836
blob_reset(&b);
837837
blob_reset(&delta);
838838
}
839839
}
840840
db_finalize(&q);
841
- diff_end(diffFlags, nErr);
841
+ diff_end(pCfg->diffFlags, nErr);
842842
if( nErr ) fossil_fatal("abort due to prior errors");
843843
}
844844
845845
846846
/*
@@ -949,37 +949,36 @@
949949
}else
950950
if( strncmp(zCmd, "diff", n)==0 ){
951951
const char *zDiffCmd = 0;
952952
const char *zBinGlob = 0;
953953
int fIncludeBinary = 0;
954
- u64 diffFlags;
955954
char *zIn;
956955
unsigned flags = 0;
957956
DiffConfig DCfg;
958957
959958
if( find_option("tk",0,0)!=0 ){
960959
db_close(0);
961960
diff_tk("patch diff", 3);
962961
return;
963962
}
964
- diffFlags = diff_options(&DCfg);
963
+ diff_options(&DCfg, zCmd[0]=='g');
965964
if( find_option("internal","i",0)==0
966
- && (diffFlags & DIFF_HTML)==0
965
+ && (DCfg.diffFlags & DIFF_HTML)==0
967966
){
968967
zDiffCmd = diff_command_external(zCmd[0]=='g');
969968
}
970
- if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
969
+ if( find_option("verbose","v",0)!=0 ) DCfg.diffFlags |= DIFF_VERBOSE;
971970
if( zDiffCmd ){
972971
zBinGlob = diff_get_binary_glob();
973972
fIncludeBinary = diff_include_binary_files();
974973
}
975974
db_find_and_open_repository(0, 0);
976975
if( find_option("force","f",0) ) flags |= PATCH_FORCE;
977976
verify_all_options();
978977
zIn = patch_find_patch_filename("apply");
979978
patch_attach(zIn, stdin);
980
- patch_diff(flags, zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
979
+ patch_diff(flags, zDiffCmd, zBinGlob, fIncludeBinary, &DCfg);
981980
fossil_free(zIn);
982981
}else
983982
if( strncmp(zCmd, "pull", n)==0 ){
984983
FILE *pIn = 0;
985984
unsigned flags = 0;
986985
--- src/patch.c
+++ src/patch.c
@@ -720,15 +720,15 @@
720 static void patch_diff(
721 unsigned mFlags, /* Patch flags. only -f is allowed */
722 const char *zDiffCmd, /* Command used for diffing */
723 const char *zBinGlob, /* GLOB pattern to determine binary files */
724 int fIncludeBinary, /* Do diffs against binary files */
725 u64 diffFlags /* Other diff flags */
726 ){
727 int nErr = 0;
728 Stmt q;
729 int bWebpage = (diffFlags & DIFF_WEBPAGE)!=0;
730 Blob empty;
731 blob_zero(&empty);
732
733 if( (mFlags & PATCH_FORCE)==0 ){
734 /* Check to ensure that the patch is against the repository that
@@ -764,11 +764,11 @@
764 "in the %s repository", zBaseline, g.zRepositoryName);
765 }
766 }
767 }
768
769 diff_begin(diffFlags);
770 db_prepare(&q,
771 "SELECT"
772 " (SELECT blob.rid FROM blob WHERE blob.uuid=chng.hash),"
773 " pathname," /* 1: new pathname */
774 " origname," /* 2: original pathname. Null if not renamed */
@@ -804,25 +804,25 @@
804 zName = db_column_text(&q, 1);
805 rid = db_column_int(&q, 0);
806
807 if( db_column_type(&q,3)==SQLITE_NULL ){
808 if( !bWebpage ) fossil_print("DELETE %s\n", zName);
809 diff_print_index(zName, diffFlags, 0);
810 isBin2 = 0;
811 content_get(rid, &a);
812 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
813 diff_file_mem(&a, &empty, isBin1, isBin2, zName, zDiffCmd,
814 zBinGlob, fIncludeBinary, diffFlags);
815 }else if( rid==0 ){
816 db_ephemeral_blob(&q, 3, &a);
817 blob_uncompress(&a, &a);
818 if( !bWebpage ) fossil_print("ADDED %s\n", zName);
819 diff_print_index(zName, diffFlags, 0);
820 isBin1 = 0;
821 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
822 diff_file_mem(&empty, &a, isBin1, isBin2, zName, zDiffCmd,
823 zBinGlob, fIncludeBinary, diffFlags);
824 blob_reset(&a);
825 }else if( db_column_bytes(&q, 3)>0 ){
826 Blob delta;
827 db_ephemeral_blob(&q, 3, &delta);
828 blob_uncompress(&delta, &delta);
@@ -829,18 +829,18 @@
829 content_get(rid, &a);
830 blob_delta_apply(&a, &delta, &b);
831 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
832 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
833 diff_file_mem(&a, &b, isBin1, isBin2, zName,
834 zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
835 blob_reset(&a);
836 blob_reset(&b);
837 blob_reset(&delta);
838 }
839 }
840 db_finalize(&q);
841 diff_end(diffFlags, nErr);
842 if( nErr ) fossil_fatal("abort due to prior errors");
843 }
844
845
846 /*
@@ -949,37 +949,36 @@
949 }else
950 if( strncmp(zCmd, "diff", n)==0 ){
951 const char *zDiffCmd = 0;
952 const char *zBinGlob = 0;
953 int fIncludeBinary = 0;
954 u64 diffFlags;
955 char *zIn;
956 unsigned flags = 0;
957 DiffConfig DCfg;
958
959 if( find_option("tk",0,0)!=0 ){
960 db_close(0);
961 diff_tk("patch diff", 3);
962 return;
963 }
964 diffFlags = diff_options(&DCfg);
965 if( find_option("internal","i",0)==0
966 && (diffFlags & DIFF_HTML)==0
967 ){
968 zDiffCmd = diff_command_external(zCmd[0]=='g');
969 }
970 if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
971 if( zDiffCmd ){
972 zBinGlob = diff_get_binary_glob();
973 fIncludeBinary = diff_include_binary_files();
974 }
975 db_find_and_open_repository(0, 0);
976 if( find_option("force","f",0) ) flags |= PATCH_FORCE;
977 verify_all_options();
978 zIn = patch_find_patch_filename("apply");
979 patch_attach(zIn, stdin);
980 patch_diff(flags, zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
981 fossil_free(zIn);
982 }else
983 if( strncmp(zCmd, "pull", n)==0 ){
984 FILE *pIn = 0;
985 unsigned flags = 0;
986
--- src/patch.c
+++ src/patch.c
@@ -720,15 +720,15 @@
720 static void patch_diff(
721 unsigned mFlags, /* Patch flags. only -f is allowed */
722 const char *zDiffCmd, /* Command used for diffing */
723 const char *zBinGlob, /* GLOB pattern to determine binary files */
724 int fIncludeBinary, /* Do diffs against binary files */
725 DiffConfig *pCfg /* Diff options */
726 ){
727 int nErr = 0;
728 Stmt q;
729 int bWebpage = (pCfg->diffFlags & DIFF_WEBPAGE)!=0;
730 Blob empty;
731 blob_zero(&empty);
732
733 if( (mFlags & PATCH_FORCE)==0 ){
734 /* Check to ensure that the patch is against the repository that
@@ -764,11 +764,11 @@
764 "in the %s repository", zBaseline, g.zRepositoryName);
765 }
766 }
767 }
768
769 diff_begin(pCfg->diffFlags);
770 db_prepare(&q,
771 "SELECT"
772 " (SELECT blob.rid FROM blob WHERE blob.uuid=chng.hash),"
773 " pathname," /* 1: new pathname */
774 " origname," /* 2: original pathname. Null if not renamed */
@@ -804,25 +804,25 @@
804 zName = db_column_text(&q, 1);
805 rid = db_column_int(&q, 0);
806
807 if( db_column_type(&q,3)==SQLITE_NULL ){
808 if( !bWebpage ) fossil_print("DELETE %s\n", zName);
809 diff_print_index(zName, pCfg->diffFlags, 0);
810 isBin2 = 0;
811 content_get(rid, &a);
812 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
813 diff_file_mem(&a, &empty, isBin1, isBin2, zName, zDiffCmd,
814 zBinGlob, fIncludeBinary, pCfg->diffFlags);
815 }else if( rid==0 ){
816 db_ephemeral_blob(&q, 3, &a);
817 blob_uncompress(&a, &a);
818 if( !bWebpage ) fossil_print("ADDED %s\n", zName);
819 diff_print_index(zName, pCfg->diffFlags, 0);
820 isBin1 = 0;
821 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
822 diff_file_mem(&empty, &a, isBin1, isBin2, zName, zDiffCmd,
823 zBinGlob, fIncludeBinary, pCfg->diffFlags);
824 blob_reset(&a);
825 }else if( db_column_bytes(&q, 3)>0 ){
826 Blob delta;
827 db_ephemeral_blob(&q, 3, &delta);
828 blob_uncompress(&delta, &delta);
@@ -829,18 +829,18 @@
829 content_get(rid, &a);
830 blob_delta_apply(&a, &delta, &b);
831 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
832 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
833 diff_file_mem(&a, &b, isBin1, isBin2, zName,
834 zDiffCmd, zBinGlob, fIncludeBinary, pCfg->diffFlags);
835 blob_reset(&a);
836 blob_reset(&b);
837 blob_reset(&delta);
838 }
839 }
840 db_finalize(&q);
841 diff_end(pCfg->diffFlags, nErr);
842 if( nErr ) fossil_fatal("abort due to prior errors");
843 }
844
845
846 /*
@@ -949,37 +949,36 @@
949 }else
950 if( strncmp(zCmd, "diff", n)==0 ){
951 const char *zDiffCmd = 0;
952 const char *zBinGlob = 0;
953 int fIncludeBinary = 0;
 
954 char *zIn;
955 unsigned flags = 0;
956 DiffConfig DCfg;
957
958 if( find_option("tk",0,0)!=0 ){
959 db_close(0);
960 diff_tk("patch diff", 3);
961 return;
962 }
963 diff_options(&DCfg, zCmd[0]=='g');
964 if( find_option("internal","i",0)==0
965 && (DCfg.diffFlags & DIFF_HTML)==0
966 ){
967 zDiffCmd = diff_command_external(zCmd[0]=='g');
968 }
969 if( find_option("verbose","v",0)!=0 ) DCfg.diffFlags |= DIFF_VERBOSE;
970 if( zDiffCmd ){
971 zBinGlob = diff_get_binary_glob();
972 fIncludeBinary = diff_include_binary_files();
973 }
974 db_find_and_open_repository(0, 0);
975 if( find_option("force","f",0) ) flags |= PATCH_FORCE;
976 verify_all_options();
977 zIn = patch_find_patch_filename("apply");
978 patch_attach(zIn, stdin);
979 patch_diff(flags, zDiffCmd, zBinGlob, fIncludeBinary, &DCfg);
980 fossil_free(zIn);
981 }else
982 if( strncmp(zCmd, "pull", n)==0 ){
983 FILE *pIn = 0;
984 unsigned flags = 0;
985
+16 -18
--- src/stash.c
+++ src/stash.c
@@ -406,17 +406,17 @@
406406
int stashid, /* The stash entry to diff */
407407
const char *zDiffCmd, /* Command used for diffing */
408408
const char *zBinGlob, /* GLOB pattern to determine binary files */
409409
int fBaseline, /* Diff against original baseline check-in if true */
410410
int fIncludeBinary, /* Do diffs against binary files */
411
- u64 diffFlags /* Other diff flags */
411
+ DiffConfig *pCfg /* Diff formatting options */
412412
){
413413
Stmt q;
414414
Blob empty;
415
- int bWebpage = (diffFlags & DIFF_WEBPAGE)!=0;
415
+ int bWebpage = (pCfg->diffFlags & DIFF_WEBPAGE)!=0;
416416
blob_zero(&empty);
417
- diff_begin(diffFlags);
417
+ diff_begin(pCfg->diffFlags);
418418
db_prepare(&q,
419419
"SELECT blob.rid, isRemoved, isExec, isLink, origname, newname, delta"
420420
" FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash",
421421
stashid
422422
);
@@ -430,56 +430,56 @@
430430
char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
431431
Blob a, b;
432432
if( rid==0 ){
433433
db_ephemeral_blob(&q, 6, &a);
434434
if( !bWebpage ) fossil_print("ADDED %s\n", zNew);
435
- diff_print_index(zNew, diffFlags, 0);
435
+ diff_print_index(zNew, pCfg->diffFlags, 0);
436436
isBin1 = 0;
437437
isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
438438
diff_file_mem(&empty, &a, isBin1, isBin2, zNew, zDiffCmd,
439
- zBinGlob, fIncludeBinary, diffFlags);
439
+ zBinGlob, fIncludeBinary, pCfg->diffFlags);
440440
}else if( isRemoved ){
441441
if( !bWebpage) fossil_print("DELETE %s\n", zOrig);
442
- diff_print_index(zNew, diffFlags, 0);
442
+ diff_print_index(zNew, pCfg->diffFlags, 0);
443443
isBin2 = 0;
444444
if( fBaseline ){
445445
content_get(rid, &a);
446446
isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
447447
diff_file_mem(&a, &empty, isBin1, isBin2, zOrig, zDiffCmd,
448
- zBinGlob, fIncludeBinary, diffFlags);
448
+ zBinGlob, fIncludeBinary, pCfg->diffFlags);
449449
}
450450
}else{
451451
Blob delta;
452452
int isOrigLink = file_islink(zOPath);
453453
db_ephemeral_blob(&q, 6, &delta);
454454
if( !bWebpage ) fossil_print("CHANGED %s\n", zNew);
455455
if( !isOrigLink != !isLink ){
456
- diff_print_index(zNew, diffFlags, 0);
457
- diff_print_filenames(zOrig, zNew, diffFlags, 0);
456
+ diff_print_index(zNew, pCfg->diffFlags, 0);
457
+ diff_print_filenames(zOrig, zNew, pCfg->diffFlags, 0);
458458
printf(DIFF_CANNOT_COMPUTE_SYMLINK);
459459
}else{
460460
content_get(rid, &a);
461461
blob_delta_apply(&a, &delta, &b);
462462
isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
463463
isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
464464
if( fBaseline ){
465465
diff_file_mem(&a, &b, isBin1, isBin2, zNew,
466
- zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
466
+ zDiffCmd, zBinGlob, fIncludeBinary, pCfg->diffFlags);
467467
}else{
468468
/*Diff with file on disk using fSwapDiff=1 to show the diff in the
469469
same direction as if fBaseline=1.*/
470470
diff_file(&b, isBin2, zOPath, zNew, zDiffCmd,
471
- zBinGlob, fIncludeBinary, diffFlags, 1, 0);
471
+ zBinGlob, fIncludeBinary, pCfg->diffFlags, 1, 0);
472472
}
473473
blob_reset(&a);
474474
blob_reset(&b);
475475
}
476476
blob_reset(&delta);
477477
}
478478
}
479479
db_finalize(&q);
480
- diff_end(diffFlags, 0);
480
+ diff_end(pCfg->diffFlags, 0);
481481
}
482482
483483
/*
484484
** Drop the indicated stash
485485
*/
@@ -744,11 +744,10 @@
744744
){
745745
const char *zDiffCmd = 0;
746746
const char *zBinGlob = 0;
747747
int fIncludeBinary = 0;
748748
int fBaseline = 0;
749
- u64 diffFlags;
750749
DiffConfig DCfg;
751750
752751
if( strstr(zCmd,"show")!=0 || strstr(zCmd,"cat")!=0 ){
753752
fBaseline = 1;
754753
}
@@ -755,25 +754,24 @@
755754
if( find_option("tk",0,0)!=0 ){
756755
db_close(0);
757756
diff_tk(fBaseline ? "stash show" : "stash diff", 3);
758757
return;
759758
}
760
- diffFlags = diff_options(&DCfg);
759
+ diff_options(&DCfg, zCmd[0]=='g');
761760
if( find_option("internal","i",0)==0
762
- && (diffFlags & DIFF_HTML)==0
761
+ && (DCfg.diffFlags & DIFF_HTML)==0
763762
){
764763
zDiffCmd = diff_command_external(zCmd[0]=='g');
765764
}
766
- if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
765
+ if( find_option("verbose","v",0)!=0 ) DCfg.diffFlags |= DIFF_VERBOSE;
767766
if( g.argc>4 ) usage(mprintf("%s ?STASHID? ?DIFF-OPTIONS?", zCmd));
768767
if( zDiffCmd ){
769768
zBinGlob = diff_get_binary_glob();
770769
fIncludeBinary = diff_include_binary_files();
771770
}
772771
stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0);
773
- stash_diff(stashid, zDiffCmd, zBinGlob, fBaseline, fIncludeBinary,
774
- diffFlags);
772
+ stash_diff(stashid, zDiffCmd, zBinGlob, fBaseline, fIncludeBinary, &DCfg);
775773
}else
776774
if( memcmp(zCmd, "help", nCmd)==0 ){
777775
g.argv[1] = "help";
778776
g.argv[2] = "stash";
779777
g.argc = 3;
780778
--- src/stash.c
+++ src/stash.c
@@ -406,17 +406,17 @@
406 int stashid, /* The stash entry to diff */
407 const char *zDiffCmd, /* Command used for diffing */
408 const char *zBinGlob, /* GLOB pattern to determine binary files */
409 int fBaseline, /* Diff against original baseline check-in if true */
410 int fIncludeBinary, /* Do diffs against binary files */
411 u64 diffFlags /* Other diff flags */
412 ){
413 Stmt q;
414 Blob empty;
415 int bWebpage = (diffFlags & DIFF_WEBPAGE)!=0;
416 blob_zero(&empty);
417 diff_begin(diffFlags);
418 db_prepare(&q,
419 "SELECT blob.rid, isRemoved, isExec, isLink, origname, newname, delta"
420 " FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash",
421 stashid
422 );
@@ -430,56 +430,56 @@
430 char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
431 Blob a, b;
432 if( rid==0 ){
433 db_ephemeral_blob(&q, 6, &a);
434 if( !bWebpage ) fossil_print("ADDED %s\n", zNew);
435 diff_print_index(zNew, diffFlags, 0);
436 isBin1 = 0;
437 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
438 diff_file_mem(&empty, &a, isBin1, isBin2, zNew, zDiffCmd,
439 zBinGlob, fIncludeBinary, diffFlags);
440 }else if( isRemoved ){
441 if( !bWebpage) fossil_print("DELETE %s\n", zOrig);
442 diff_print_index(zNew, diffFlags, 0);
443 isBin2 = 0;
444 if( fBaseline ){
445 content_get(rid, &a);
446 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
447 diff_file_mem(&a, &empty, isBin1, isBin2, zOrig, zDiffCmd,
448 zBinGlob, fIncludeBinary, diffFlags);
449 }
450 }else{
451 Blob delta;
452 int isOrigLink = file_islink(zOPath);
453 db_ephemeral_blob(&q, 6, &delta);
454 if( !bWebpage ) fossil_print("CHANGED %s\n", zNew);
455 if( !isOrigLink != !isLink ){
456 diff_print_index(zNew, diffFlags, 0);
457 diff_print_filenames(zOrig, zNew, diffFlags, 0);
458 printf(DIFF_CANNOT_COMPUTE_SYMLINK);
459 }else{
460 content_get(rid, &a);
461 blob_delta_apply(&a, &delta, &b);
462 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
463 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
464 if( fBaseline ){
465 diff_file_mem(&a, &b, isBin1, isBin2, zNew,
466 zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
467 }else{
468 /*Diff with file on disk using fSwapDiff=1 to show the diff in the
469 same direction as if fBaseline=1.*/
470 diff_file(&b, isBin2, zOPath, zNew, zDiffCmd,
471 zBinGlob, fIncludeBinary, diffFlags, 1, 0);
472 }
473 blob_reset(&a);
474 blob_reset(&b);
475 }
476 blob_reset(&delta);
477 }
478 }
479 db_finalize(&q);
480 diff_end(diffFlags, 0);
481 }
482
483 /*
484 ** Drop the indicated stash
485 */
@@ -744,11 +744,10 @@
744 ){
745 const char *zDiffCmd = 0;
746 const char *zBinGlob = 0;
747 int fIncludeBinary = 0;
748 int fBaseline = 0;
749 u64 diffFlags;
750 DiffConfig DCfg;
751
752 if( strstr(zCmd,"show")!=0 || strstr(zCmd,"cat")!=0 ){
753 fBaseline = 1;
754 }
@@ -755,25 +754,24 @@
755 if( find_option("tk",0,0)!=0 ){
756 db_close(0);
757 diff_tk(fBaseline ? "stash show" : "stash diff", 3);
758 return;
759 }
760 diffFlags = diff_options(&DCfg);
761 if( find_option("internal","i",0)==0
762 && (diffFlags & DIFF_HTML)==0
763 ){
764 zDiffCmd = diff_command_external(zCmd[0]=='g');
765 }
766 if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
767 if( g.argc>4 ) usage(mprintf("%s ?STASHID? ?DIFF-OPTIONS?", zCmd));
768 if( zDiffCmd ){
769 zBinGlob = diff_get_binary_glob();
770 fIncludeBinary = diff_include_binary_files();
771 }
772 stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0);
773 stash_diff(stashid, zDiffCmd, zBinGlob, fBaseline, fIncludeBinary,
774 diffFlags);
775 }else
776 if( memcmp(zCmd, "help", nCmd)==0 ){
777 g.argv[1] = "help";
778 g.argv[2] = "stash";
779 g.argc = 3;
780
--- src/stash.c
+++ src/stash.c
@@ -406,17 +406,17 @@
406 int stashid, /* The stash entry to diff */
407 const char *zDiffCmd, /* Command used for diffing */
408 const char *zBinGlob, /* GLOB pattern to determine binary files */
409 int fBaseline, /* Diff against original baseline check-in if true */
410 int fIncludeBinary, /* Do diffs against binary files */
411 DiffConfig *pCfg /* Diff formatting options */
412 ){
413 Stmt q;
414 Blob empty;
415 int bWebpage = (pCfg->diffFlags & DIFF_WEBPAGE)!=0;
416 blob_zero(&empty);
417 diff_begin(pCfg->diffFlags);
418 db_prepare(&q,
419 "SELECT blob.rid, isRemoved, isExec, isLink, origname, newname, delta"
420 " FROM stashfile, blob WHERE stashid=%d AND blob.uuid=stashfile.hash",
421 stashid
422 );
@@ -430,56 +430,56 @@
430 char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
431 Blob a, b;
432 if( rid==0 ){
433 db_ephemeral_blob(&q, 6, &a);
434 if( !bWebpage ) fossil_print("ADDED %s\n", zNew);
435 diff_print_index(zNew, pCfg->diffFlags, 0);
436 isBin1 = 0;
437 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
438 diff_file_mem(&empty, &a, isBin1, isBin2, zNew, zDiffCmd,
439 zBinGlob, fIncludeBinary, pCfg->diffFlags);
440 }else if( isRemoved ){
441 if( !bWebpage) fossil_print("DELETE %s\n", zOrig);
442 diff_print_index(zNew, pCfg->diffFlags, 0);
443 isBin2 = 0;
444 if( fBaseline ){
445 content_get(rid, &a);
446 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
447 diff_file_mem(&a, &empty, isBin1, isBin2, zOrig, zDiffCmd,
448 zBinGlob, fIncludeBinary, pCfg->diffFlags);
449 }
450 }else{
451 Blob delta;
452 int isOrigLink = file_islink(zOPath);
453 db_ephemeral_blob(&q, 6, &delta);
454 if( !bWebpage ) fossil_print("CHANGED %s\n", zNew);
455 if( !isOrigLink != !isLink ){
456 diff_print_index(zNew, pCfg->diffFlags, 0);
457 diff_print_filenames(zOrig, zNew, pCfg->diffFlags, 0);
458 printf(DIFF_CANNOT_COMPUTE_SYMLINK);
459 }else{
460 content_get(rid, &a);
461 blob_delta_apply(&a, &delta, &b);
462 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
463 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
464 if( fBaseline ){
465 diff_file_mem(&a, &b, isBin1, isBin2, zNew,
466 zDiffCmd, zBinGlob, fIncludeBinary, pCfg->diffFlags);
467 }else{
468 /*Diff with file on disk using fSwapDiff=1 to show the diff in the
469 same direction as if fBaseline=1.*/
470 diff_file(&b, isBin2, zOPath, zNew, zDiffCmd,
471 zBinGlob, fIncludeBinary, pCfg->diffFlags, 1, 0);
472 }
473 blob_reset(&a);
474 blob_reset(&b);
475 }
476 blob_reset(&delta);
477 }
478 }
479 db_finalize(&q);
480 diff_end(pCfg->diffFlags, 0);
481 }
482
483 /*
484 ** Drop the indicated stash
485 */
@@ -744,11 +744,10 @@
744 ){
745 const char *zDiffCmd = 0;
746 const char *zBinGlob = 0;
747 int fIncludeBinary = 0;
748 int fBaseline = 0;
 
749 DiffConfig DCfg;
750
751 if( strstr(zCmd,"show")!=0 || strstr(zCmd,"cat")!=0 ){
752 fBaseline = 1;
753 }
@@ -755,25 +754,24 @@
754 if( find_option("tk",0,0)!=0 ){
755 db_close(0);
756 diff_tk(fBaseline ? "stash show" : "stash diff", 3);
757 return;
758 }
759 diff_options(&DCfg, zCmd[0]=='g');
760 if( find_option("internal","i",0)==0
761 && (DCfg.diffFlags & DIFF_HTML)==0
762 ){
763 zDiffCmd = diff_command_external(zCmd[0]=='g');
764 }
765 if( find_option("verbose","v",0)!=0 ) DCfg.diffFlags |= DIFF_VERBOSE;
766 if( g.argc>4 ) usage(mprintf("%s ?STASHID? ?DIFF-OPTIONS?", zCmd));
767 if( zDiffCmd ){
768 zBinGlob = diff_get_binary_glob();
769 fIncludeBinary = diff_include_binary_files();
770 }
771 stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0);
772 stash_diff(stashid, zDiffCmd, zBinGlob, fBaseline, fIncludeBinary, &DCfg);
 
773 }else
774 if( memcmp(zCmd, "help", nCmd)==0 ){
775 g.argv[1] = "help";
776 g.argv[2] = "stash";
777 g.argc = 3;
778

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button