Fossil SCM

Improvements to the output of the "diff" command so that it is closer to standards.

drh 2008-10-24 10:56 trunk
Commit 85670cfcc852fdf5ca15a761185dadf9f02310d2
1 file changed +14 -6
+14 -6
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -93,10 +93,14 @@
9393
}else if( isDeleted ){
9494
printf("DELETED %s\n", zPathname);
9595
}else if( isChnged==3 ){
9696
printf("ADDED_BY_MERGE %s\n", zPathname);
9797
}else{
98
+ printf("Index: %s\n======================================="
99
+ "============================\n",
100
+ zPathname
101
+ );
98102
shell_escape(&cmd, zFullName);
99103
printf("%s\n", blob_str(&cmd));
100104
fflush(stdout);
101105
system(blob_str(&cmd));
102106
}
@@ -132,18 +136,21 @@
132136
** %fossil setting gdiff-command meld
133137
** %fossil setting gdiff-command xxdiff
134138
** %fossil setting gdiff-command kdiff3
135139
*/
136140
void diff_cmd(void){
137
- int isGDiff = g.argv[1][0]=='g';
138
- const char *zFile, *zRevision;
139
- Blob cmd;
140
- Blob fname;
141
+ int isGDiff; /* True for gdiff. False for normal diff */
142
+ const char *zFile; /* Name of file to diff */
143
+ const char *zRevision; /* Version of file to diff against current */
144
+ Blob cmd; /* The diff command-line for external diff */
145
+ Blob fname; /* */
141146
Blob vname;
142147
Blob record;
143
- int cnt=0,internalDiff;
148
+ int cnt=0;
149
+ int internalDiff; /* True to use the internal diff engine */
144150
151
+ isGDiff = g.argv[1][0]=='g';
145152
internalDiff = find_option("internal","i",0)!=0;
146153
zRevision = find_option("revision", "r", 1);
147154
verify_all_options();
148155
db_must_be_within_tree();
149156
@@ -178,11 +185,11 @@
178185
}while( access(blob_str(&vname),0)==0 );
179186
180187
if( zRevision==0 ){
181188
int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
182189
if( rid==0 ){
183
- fossil_panic("no history for file: %b", &fname);
190
+ fossil_fatal("no history for file: %b", &fname);
184191
}
185192
content_get(rid, &record);
186193
}else{
187194
historical_version_of_file(zRevision, blob_str(&fname), &record);
188195
}
@@ -191,10 +198,11 @@
191198
Blob current;
192199
blob_zero(&current);
193200
blob_read_from_file(&current, zFile);
194201
blob_zero(&out);
195202
text_diff(&record, &current, &out, 5);
203
+ printf("--- %s\n+++ %s\n", blob_str(&fname), blob_str(&fname));
196204
printf("%s\n", blob_str(&out));
197205
blob_reset(&current);
198206
blob_reset(&out);
199207
}else{
200208
blob_write_to_file(&record, blob_str(&vname));
201209
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -93,10 +93,14 @@
93 }else if( isDeleted ){
94 printf("DELETED %s\n", zPathname);
95 }else if( isChnged==3 ){
96 printf("ADDED_BY_MERGE %s\n", zPathname);
97 }else{
 
 
 
 
98 shell_escape(&cmd, zFullName);
99 printf("%s\n", blob_str(&cmd));
100 fflush(stdout);
101 system(blob_str(&cmd));
102 }
@@ -132,18 +136,21 @@
132 ** %fossil setting gdiff-command meld
133 ** %fossil setting gdiff-command xxdiff
134 ** %fossil setting gdiff-command kdiff3
135 */
136 void diff_cmd(void){
137 int isGDiff = g.argv[1][0]=='g';
138 const char *zFile, *zRevision;
139 Blob cmd;
140 Blob fname;
 
141 Blob vname;
142 Blob record;
143 int cnt=0,internalDiff;
 
144
 
145 internalDiff = find_option("internal","i",0)!=0;
146 zRevision = find_option("revision", "r", 1);
147 verify_all_options();
148 db_must_be_within_tree();
149
@@ -178,11 +185,11 @@
178 }while( access(blob_str(&vname),0)==0 );
179
180 if( zRevision==0 ){
181 int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
182 if( rid==0 ){
183 fossil_panic("no history for file: %b", &fname);
184 }
185 content_get(rid, &record);
186 }else{
187 historical_version_of_file(zRevision, blob_str(&fname), &record);
188 }
@@ -191,10 +198,11 @@
191 Blob current;
192 blob_zero(&current);
193 blob_read_from_file(&current, zFile);
194 blob_zero(&out);
195 text_diff(&record, &current, &out, 5);
 
196 printf("%s\n", blob_str(&out));
197 blob_reset(&current);
198 blob_reset(&out);
199 }else{
200 blob_write_to_file(&record, blob_str(&vname));
201
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -93,10 +93,14 @@
93 }else if( isDeleted ){
94 printf("DELETED %s\n", zPathname);
95 }else if( isChnged==3 ){
96 printf("ADDED_BY_MERGE %s\n", zPathname);
97 }else{
98 printf("Index: %s\n======================================="
99 "============================\n",
100 zPathname
101 );
102 shell_escape(&cmd, zFullName);
103 printf("%s\n", blob_str(&cmd));
104 fflush(stdout);
105 system(blob_str(&cmd));
106 }
@@ -132,18 +136,21 @@
136 ** %fossil setting gdiff-command meld
137 ** %fossil setting gdiff-command xxdiff
138 ** %fossil setting gdiff-command kdiff3
139 */
140 void diff_cmd(void){
141 int isGDiff; /* True for gdiff. False for normal diff */
142 const char *zFile; /* Name of file to diff */
143 const char *zRevision; /* Version of file to diff against current */
144 Blob cmd; /* The diff command-line for external diff */
145 Blob fname; /* */
146 Blob vname;
147 Blob record;
148 int cnt=0;
149 int internalDiff; /* True to use the internal diff engine */
150
151 isGDiff = g.argv[1][0]=='g';
152 internalDiff = find_option("internal","i",0)!=0;
153 zRevision = find_option("revision", "r", 1);
154 verify_all_options();
155 db_must_be_within_tree();
156
@@ -178,11 +185,11 @@
185 }while( access(blob_str(&vname),0)==0 );
186
187 if( zRevision==0 ){
188 int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
189 if( rid==0 ){
190 fossil_fatal("no history for file: %b", &fname);
191 }
192 content_get(rid, &record);
193 }else{
194 historical_version_of_file(zRevision, blob_str(&fname), &record);
195 }
@@ -191,10 +198,11 @@
198 Blob current;
199 blob_zero(&current);
200 blob_read_from_file(&current, zFile);
201 blob_zero(&out);
202 text_diff(&record, &current, &out, 5);
203 printf("--- %s\n+++ %s\n", blob_str(&fname), blob_str(&fname));
204 printf("%s\n", blob_str(&out));
205 blob_reset(&current);
206 blob_reset(&out);
207 }else{
208 blob_write_to_file(&record, blob_str(&vname));
209

Keyboard Shortcuts

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