Fossil SCM

Add gshow and gcat command to allow to use gdiff-command when diffing the stash against baseline. When using gdiff, call external tool directly with the file from the checkout, it's usefull when merging change manually using the external tool.

mgagnon 2017-03-03 14:31 UTC trunk
Commit 06b167526b357207f249f628533c8ab6aa023064
2 files changed +21 -7 +35 -32
+21 -7
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -151,10 +151,13 @@
151151
/*
152152
** Show the difference between two files, one in memory and one on disk.
153153
**
154154
** The difference is the set of edits needed to transform pFile1 into
155155
** zFile2. The content of pFile1 is in memory. zFile2 exists on disk.
156
+**
157
+** If fSwapDiff is 1, show the set of edits to transform zFile2 into pFile1
158
+** instead of the opposite.
156159
**
157160
** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
158161
** command zDiffCmd to do the diffing.
159162
**
160163
** When using an external diff program, zBinGlob contains the GLOB patterns
@@ -167,11 +170,12 @@
167170
const char *zFile2, /* On disk content to compare to */
168171
const char *zName, /* Display name of the file */
169172
const char *zDiffCmd, /* Command for comparison */
170173
const char *zBinGlob, /* Treat file names matching this as binary */
171174
int fIncludeBinary, /* Include binary files for external diff */
172
- u64 diffFlags /* Flags to control the diff */
175
+ u64 diffFlags, /* Flags to control the diff */
176
+ int fSwapDiff /* Diff from Zfile2 to Pfile1 */
173177
){
174178
if( zDiffCmd==0 ){
175179
Blob out; /* Diff output text */
176180
Blob file2; /* Content of zFile2 */
177181
const char *zName2; /* Name of zFile2 for display */
@@ -194,11 +198,15 @@
194198
if( blob_compare(pFile1, &file2) ){
195199
fossil_print("CHANGED %s\n", zName);
196200
}
197201
}else{
198202
blob_zero(&out);
199
- text_diff(pFile1, &file2, &out, 0, diffFlags);
203
+ if( fSwapDiff ){
204
+ text_diff(&file2, pFile1, &out, 0, diffFlags);
205
+ }else{
206
+ text_diff(pFile1, &file2, &out, 0, diffFlags);
207
+ }
200208
if( blob_size(&out) ){
201209
diff_print_filenames(zName, zName2, diffFlags);
202210
fossil_print("%s\n", blob_str(&out));
203211
}
204212
blob_reset(&out);
@@ -252,13 +260,19 @@
252260
blob_write_to_file(pFile1, blob_str(&nameFile1));
253261
254262
/* Construct the external diff command */
255263
blob_zero(&cmd);
256264
blob_appendf(&cmd, "%s ", zDiffCmd);
257
- shell_escape(&cmd, blob_str(&nameFile1));
258
- blob_append(&cmd, " ", 1);
259
- shell_escape(&cmd, zFile2);
265
+ if( fSwapDiff ){
266
+ shell_escape(&cmd, zFile2);
267
+ blob_append(&cmd, " ", 1);
268
+ shell_escape(&cmd, blob_str(&nameFile1));
269
+ }else{
270
+ shell_escape(&cmd, blob_str(&nameFile1));
271
+ blob_append(&cmd, " ", 1);
272
+ shell_escape(&cmd, zFile2);
273
+ }
260274
261275
/* Run the external diff command */
262276
fossil_system(blob_str(&cmd));
263277
264278
/* Delete the temporary file and clean up memory used */
@@ -482,11 +496,11 @@
482496
blob_zero(&content);
483497
}
484498
isBin = fIncludeBinary ? 0 : looks_like_binary(&content);
485499
diff_print_index(zPathname, diffFlags);
486500
diff_file(&content, isBin, zFullName, zPathname, zDiffCmd,
487
- zBinGlob, fIncludeBinary, diffFlags);
501
+ zBinGlob, fIncludeBinary, diffFlags, 0);
488502
blob_reset(&content);
489503
}
490504
blob_reset(&fname);
491505
}
492506
db_finalize(&q);
@@ -519,11 +533,11 @@
519533
const char *zFile = (const char*)db_column_text(&q, 0);
520534
if( !file_dir_match(pFileDir, zFile) ) continue;
521535
zFullName = mprintf("%s%s", g.zLocalRoot, zFile);
522536
db_column_blob(&q, 1, &content);
523537
diff_file(&content, 0, zFullName, zFile,
524
- zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
538
+ zDiffCmd, zBinGlob, fIncludeBinary, diffFlags, 0);
525539
fossil_free(zFullName);
526540
blob_reset(&content);
527541
}
528542
db_finalize(&q);
529543
}
530544
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -151,10 +151,13 @@
151 /*
152 ** Show the difference between two files, one in memory and one on disk.
153 **
154 ** The difference is the set of edits needed to transform pFile1 into
155 ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk.
 
 
 
156 **
157 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
158 ** command zDiffCmd to do the diffing.
159 **
160 ** When using an external diff program, zBinGlob contains the GLOB patterns
@@ -167,11 +170,12 @@
167 const char *zFile2, /* On disk content to compare to */
168 const char *zName, /* Display name of the file */
169 const char *zDiffCmd, /* Command for comparison */
170 const char *zBinGlob, /* Treat file names matching this as binary */
171 int fIncludeBinary, /* Include binary files for external diff */
172 u64 diffFlags /* Flags to control the diff */
 
173 ){
174 if( zDiffCmd==0 ){
175 Blob out; /* Diff output text */
176 Blob file2; /* Content of zFile2 */
177 const char *zName2; /* Name of zFile2 for display */
@@ -194,11 +198,15 @@
194 if( blob_compare(pFile1, &file2) ){
195 fossil_print("CHANGED %s\n", zName);
196 }
197 }else{
198 blob_zero(&out);
199 text_diff(pFile1, &file2, &out, 0, diffFlags);
 
 
 
 
200 if( blob_size(&out) ){
201 diff_print_filenames(zName, zName2, diffFlags);
202 fossil_print("%s\n", blob_str(&out));
203 }
204 blob_reset(&out);
@@ -252,13 +260,19 @@
252 blob_write_to_file(pFile1, blob_str(&nameFile1));
253
254 /* Construct the external diff command */
255 blob_zero(&cmd);
256 blob_appendf(&cmd, "%s ", zDiffCmd);
257 shell_escape(&cmd, blob_str(&nameFile1));
258 blob_append(&cmd, " ", 1);
259 shell_escape(&cmd, zFile2);
 
 
 
 
 
 
260
261 /* Run the external diff command */
262 fossil_system(blob_str(&cmd));
263
264 /* Delete the temporary file and clean up memory used */
@@ -482,11 +496,11 @@
482 blob_zero(&content);
483 }
484 isBin = fIncludeBinary ? 0 : looks_like_binary(&content);
485 diff_print_index(zPathname, diffFlags);
486 diff_file(&content, isBin, zFullName, zPathname, zDiffCmd,
487 zBinGlob, fIncludeBinary, diffFlags);
488 blob_reset(&content);
489 }
490 blob_reset(&fname);
491 }
492 db_finalize(&q);
@@ -519,11 +533,11 @@
519 const char *zFile = (const char*)db_column_text(&q, 0);
520 if( !file_dir_match(pFileDir, zFile) ) continue;
521 zFullName = mprintf("%s%s", g.zLocalRoot, zFile);
522 db_column_blob(&q, 1, &content);
523 diff_file(&content, 0, zFullName, zFile,
524 zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
525 fossil_free(zFullName);
526 blob_reset(&content);
527 }
528 db_finalize(&q);
529 }
530
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -151,10 +151,13 @@
151 /*
152 ** Show the difference between two files, one in memory and one on disk.
153 **
154 ** The difference is the set of edits needed to transform pFile1 into
155 ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk.
156 **
157 ** If fSwapDiff is 1, show the set of edits to transform zFile2 into pFile1
158 ** instead of the opposite.
159 **
160 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
161 ** command zDiffCmd to do the diffing.
162 **
163 ** When using an external diff program, zBinGlob contains the GLOB patterns
@@ -167,11 +170,12 @@
170 const char *zFile2, /* On disk content to compare to */
171 const char *zName, /* Display name of the file */
172 const char *zDiffCmd, /* Command for comparison */
173 const char *zBinGlob, /* Treat file names matching this as binary */
174 int fIncludeBinary, /* Include binary files for external diff */
175 u64 diffFlags, /* Flags to control the diff */
176 int fSwapDiff /* Diff from Zfile2 to Pfile1 */
177 ){
178 if( zDiffCmd==0 ){
179 Blob out; /* Diff output text */
180 Blob file2; /* Content of zFile2 */
181 const char *zName2; /* Name of zFile2 for display */
@@ -194,11 +198,15 @@
198 if( blob_compare(pFile1, &file2) ){
199 fossil_print("CHANGED %s\n", zName);
200 }
201 }else{
202 blob_zero(&out);
203 if( fSwapDiff ){
204 text_diff(&file2, pFile1, &out, 0, diffFlags);
205 }else{
206 text_diff(pFile1, &file2, &out, 0, diffFlags);
207 }
208 if( blob_size(&out) ){
209 diff_print_filenames(zName, zName2, diffFlags);
210 fossil_print("%s\n", blob_str(&out));
211 }
212 blob_reset(&out);
@@ -252,13 +260,19 @@
260 blob_write_to_file(pFile1, blob_str(&nameFile1));
261
262 /* Construct the external diff command */
263 blob_zero(&cmd);
264 blob_appendf(&cmd, "%s ", zDiffCmd);
265 if( fSwapDiff ){
266 shell_escape(&cmd, zFile2);
267 blob_append(&cmd, " ", 1);
268 shell_escape(&cmd, blob_str(&nameFile1));
269 }else{
270 shell_escape(&cmd, blob_str(&nameFile1));
271 blob_append(&cmd, " ", 1);
272 shell_escape(&cmd, zFile2);
273 }
274
275 /* Run the external diff command */
276 fossil_system(blob_str(&cmd));
277
278 /* Delete the temporary file and clean up memory used */
@@ -482,11 +496,11 @@
496 blob_zero(&content);
497 }
498 isBin = fIncludeBinary ? 0 : looks_like_binary(&content);
499 diff_print_index(zPathname, diffFlags);
500 diff_file(&content, isBin, zFullName, zPathname, zDiffCmd,
501 zBinGlob, fIncludeBinary, diffFlags, 0);
502 blob_reset(&content);
503 }
504 blob_reset(&fname);
505 }
506 db_finalize(&q);
@@ -519,11 +533,11 @@
533 const char *zFile = (const char*)db_column_text(&q, 0);
534 if( !file_dir_match(pFileDir, zFile) ) continue;
535 zFullName = mprintf("%s%s", g.zLocalRoot, zFile);
536 db_column_blob(&q, 1, &content);
537 diff_file(&content, 0, zFullName, zFile,
538 zDiffCmd, zBinGlob, fIncludeBinary, diffFlags, 0);
539 fossil_free(zFullName);
540 blob_reset(&content);
541 }
542 db_finalize(&q);
543 }
544
+35 -32
--- src/stash.c
+++ src/stash.c
@@ -332,52 +332,45 @@
332332
isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
333333
diff_file_mem(&empty, &a, isBin1, isBin2, zNew, zDiffCmd,
334334
zBinGlob, fIncludeBinary, diffFlags);
335335
}else if( isRemoved ){
336336
fossil_print("DELETE %s\n", zOrig);
337
- if( fBaseline==0 ){
338
- if( file_wd_islink(zOPath) ){
339
- blob_read_link(&a, zOPath);
340
- }else{
341
- blob_read_from_file(&a, zOPath);
342
- }
343
- }else{
344
- content_get(rid, &a);
345
- }
346
- diff_print_index(zNew, diffFlags);
347
- isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
348
- isBin2 = 0;
349
- diff_file_mem(&a, &empty, isBin1, isBin2, zOrig, zDiffCmd,
350
- zBinGlob, fIncludeBinary, diffFlags);
351
- }else{
352
- Blob delta, disk;
337
+ diff_print_index(zNew, diffFlags);
338
+ isBin2 = 0;
339
+ if( fBaseline ){
340
+ content_get(rid, &a);
341
+ isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
342
+ diff_file_mem(&a, &empty, isBin1, isBin2, zOrig, zDiffCmd,
343
+ zBinGlob, fIncludeBinary, diffFlags);
344
+ }else{
345
+ }
346
+ }else{
347
+ Blob delta;
353348
int isOrigLink = file_wd_islink(zOPath);
354349
db_ephemeral_blob(&q, 6, &delta);
355
- if( fBaseline==0 ){
356
- if( isOrigLink ){
357
- blob_read_link(&disk, zOPath);
358
- }else{
359
- blob_read_from_file(&disk, zOPath);
360
- }
361
- }
362350
fossil_print("CHANGED %s\n", zNew);
363351
if( !isOrigLink != !isLink ){
364352
diff_print_index(zNew, diffFlags);
365353
diff_print_filenames(zOrig, zNew, diffFlags);
366354
printf(DIFF_CANNOT_COMPUTE_SYMLINK);
367355
}else{
368
- Blob *pBase = fBaseline ? &a : &disk;
369356
content_get(rid, &a);
370357
blob_delta_apply(&a, &delta, &b);
371
- isBin1 = fIncludeBinary ? 0 : looks_like_binary(pBase);
358
+ isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
372359
isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
373
- diff_file_mem(fBaseline? &a : &disk, &b, isBin1, isBin2, zNew,
374
- zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
360
+ if( fBaseline ){
361
+ diff_file_mem(&a, &b, isBin1, isBin2, zNew,
362
+ zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
363
+ }else{
364
+ /*Diff with file on disk using fSwapDiff=1 to show the diff in the
365
+ same direction as if fBaseline=1.*/
366
+ diff_file(&b, isBin2, zOPath, zNew, zDiffCmd,
367
+ zBinGlob, fIncludeBinary, diffFlags, 1);
368
+ }
375369
blob_reset(&a);
376370
blob_reset(&b);
377371
}
378
- if( !fBaseline ) blob_reset(&disk);
379372
blob_reset(&delta);
380373
}
381374
}
382375
db_finalize(&q);
383376
}
@@ -433,12 +426,15 @@
433426
**
434427
** List all changes sets currently stashed. Show information about
435428
** individual files in each changeset if -v or --verbose is used.
436429
**
437430
** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
431
+** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS?
438432
**
439
-** Show the contents of a stash.
433
+** Show the contents of a stash as a diff against it's baseline.
434
+** With gshow and gcat, gdiff-command is used instead of internal
435
+** diff logic.
440436
**
441437
** fossil stash pop
442438
** fossil stash apply ?STASHID?
443439
**
444440
** Apply STASHID or the most recently create stash to the current
@@ -460,18 +456,20 @@
460456
**
461457
** fossil stash diff ?STASHID? ?DIFF-OPTIONS?
462458
** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS?
463459
**
464460
** Show diffs of the current working directory and what that
465
-** directory would be if STASHID were applied.
461
+** directory would be if STASHID were applied. With gdiff,
462
+** gdiff-command is used instead of internal diff logic.
466463
**
467464
** SUMMARY:
468465
** fossil stash
469466
** fossil stash save ?-m|--comment COMMENT? ?FILES...?
470467
** fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?
471468
** fossil stash list|ls ?-v|--verbose? ?-W|--width <num>?
472469
** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
470
+** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS?
473471
** fossil stash pop
474472
** fossil stash apply|goto ?STASHID?
475473
** fossil stash drop|rm ?STASHID? ?-a|--all?
476474
** fossil stash diff ?STASHID? ?DIFF-OPTIONS?
477475
** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS?
@@ -654,25 +652,30 @@
654652
undo_finish();
655653
}else
656654
if( memcmp(zCmd, "diff", nCmd)==0
657655
|| memcmp(zCmd, "gdiff", nCmd)==0
658656
|| memcmp(zCmd, "show", nCmd)==0
657
+ || memcmp(zCmd, "gshow", nCmd)==0
659658
|| memcmp(zCmd, "cat", nCmd)==0
659
+ || memcmp(zCmd, "gcat", nCmd)==0
660660
){
661661
const char *zDiffCmd = 0;
662662
const char *zBinGlob = 0;
663663
int fIncludeBinary = 0;
664
- int fBaseline = zCmd[0]=='s' || zCmd[0]=='c';
664
+ int fBaseline = 0;
665665
u64 diffFlags;
666666
667
+ if( strstr(zCmd,"show")!=0 || strstr(zCmd,"cat")!=0 ){
668
+ fBaseline = 1;
669
+ }
667670
if( find_option("tk",0,0)!=0 ){
668671
db_close(0);
669672
diff_tk(fBaseline ? "stash show" : "stash diff", 3);
670673
return;
671674
}
672675
if( find_option("internal","i",0)==0 ){
673
- zDiffCmd = diff_command_external(memcmp(zCmd, "gdiff", nCmd)==0);
676
+ zDiffCmd = diff_command_external(zCmd[0]=='g');
674677
}
675678
diffFlags = diff_options();
676679
if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
677680
if( g.argc>4 ) usage(mprintf("%s ?STASHID? ?DIFF-OPTIONS?", zCmd));
678681
if( zDiffCmd ){
679682
--- src/stash.c
+++ src/stash.c
@@ -332,52 +332,45 @@
332 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
333 diff_file_mem(&empty, &a, isBin1, isBin2, zNew, zDiffCmd,
334 zBinGlob, fIncludeBinary, diffFlags);
335 }else if( isRemoved ){
336 fossil_print("DELETE %s\n", zOrig);
337 if( fBaseline==0 ){
338 if( file_wd_islink(zOPath) ){
339 blob_read_link(&a, zOPath);
340 }else{
341 blob_read_from_file(&a, zOPath);
342 }
343 }else{
344 content_get(rid, &a);
345 }
346 diff_print_index(zNew, diffFlags);
347 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
348 isBin2 = 0;
349 diff_file_mem(&a, &empty, isBin1, isBin2, zOrig, zDiffCmd,
350 zBinGlob, fIncludeBinary, diffFlags);
351 }else{
352 Blob delta, disk;
353 int isOrigLink = file_wd_islink(zOPath);
354 db_ephemeral_blob(&q, 6, &delta);
355 if( fBaseline==0 ){
356 if( isOrigLink ){
357 blob_read_link(&disk, zOPath);
358 }else{
359 blob_read_from_file(&disk, zOPath);
360 }
361 }
362 fossil_print("CHANGED %s\n", zNew);
363 if( !isOrigLink != !isLink ){
364 diff_print_index(zNew, diffFlags);
365 diff_print_filenames(zOrig, zNew, diffFlags);
366 printf(DIFF_CANNOT_COMPUTE_SYMLINK);
367 }else{
368 Blob *pBase = fBaseline ? &a : &disk;
369 content_get(rid, &a);
370 blob_delta_apply(&a, &delta, &b);
371 isBin1 = fIncludeBinary ? 0 : looks_like_binary(pBase);
372 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
373 diff_file_mem(fBaseline? &a : &disk, &b, isBin1, isBin2, zNew,
374 zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
 
 
 
 
 
 
 
375 blob_reset(&a);
376 blob_reset(&b);
377 }
378 if( !fBaseline ) blob_reset(&disk);
379 blob_reset(&delta);
380 }
381 }
382 db_finalize(&q);
383 }
@@ -433,12 +426,15 @@
433 **
434 ** List all changes sets currently stashed. Show information about
435 ** individual files in each changeset if -v or --verbose is used.
436 **
437 ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
 
438 **
439 ** Show the contents of a stash.
 
 
440 **
441 ** fossil stash pop
442 ** fossil stash apply ?STASHID?
443 **
444 ** Apply STASHID or the most recently create stash to the current
@@ -460,18 +456,20 @@
460 **
461 ** fossil stash diff ?STASHID? ?DIFF-OPTIONS?
462 ** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS?
463 **
464 ** Show diffs of the current working directory and what that
465 ** directory would be if STASHID were applied.
 
466 **
467 ** SUMMARY:
468 ** fossil stash
469 ** fossil stash save ?-m|--comment COMMENT? ?FILES...?
470 ** fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?
471 ** fossil stash list|ls ?-v|--verbose? ?-W|--width <num>?
472 ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
 
473 ** fossil stash pop
474 ** fossil stash apply|goto ?STASHID?
475 ** fossil stash drop|rm ?STASHID? ?-a|--all?
476 ** fossil stash diff ?STASHID? ?DIFF-OPTIONS?
477 ** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS?
@@ -654,25 +652,30 @@
654 undo_finish();
655 }else
656 if( memcmp(zCmd, "diff", nCmd)==0
657 || memcmp(zCmd, "gdiff", nCmd)==0
658 || memcmp(zCmd, "show", nCmd)==0
 
659 || memcmp(zCmd, "cat", nCmd)==0
 
660 ){
661 const char *zDiffCmd = 0;
662 const char *zBinGlob = 0;
663 int fIncludeBinary = 0;
664 int fBaseline = zCmd[0]=='s' || zCmd[0]=='c';
665 u64 diffFlags;
666
 
 
 
667 if( find_option("tk",0,0)!=0 ){
668 db_close(0);
669 diff_tk(fBaseline ? "stash show" : "stash diff", 3);
670 return;
671 }
672 if( find_option("internal","i",0)==0 ){
673 zDiffCmd = diff_command_external(memcmp(zCmd, "gdiff", nCmd)==0);
674 }
675 diffFlags = diff_options();
676 if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
677 if( g.argc>4 ) usage(mprintf("%s ?STASHID? ?DIFF-OPTIONS?", zCmd));
678 if( zDiffCmd ){
679
--- src/stash.c
+++ src/stash.c
@@ -332,52 +332,45 @@
332 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&a);
333 diff_file_mem(&empty, &a, isBin1, isBin2, zNew, zDiffCmd,
334 zBinGlob, fIncludeBinary, diffFlags);
335 }else if( isRemoved ){
336 fossil_print("DELETE %s\n", zOrig);
337 diff_print_index(zNew, diffFlags);
338 isBin2 = 0;
339 if( fBaseline ){
340 content_get(rid, &a);
341 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
342 diff_file_mem(&a, &empty, isBin1, isBin2, zOrig, zDiffCmd,
343 zBinGlob, fIncludeBinary, diffFlags);
344 }else{
345 }
346 }else{
347 Blob delta;
 
 
 
 
 
348 int isOrigLink = file_wd_islink(zOPath);
349 db_ephemeral_blob(&q, 6, &delta);
 
 
 
 
 
 
 
350 fossil_print("CHANGED %s\n", zNew);
351 if( !isOrigLink != !isLink ){
352 diff_print_index(zNew, diffFlags);
353 diff_print_filenames(zOrig, zNew, diffFlags);
354 printf(DIFF_CANNOT_COMPUTE_SYMLINK);
355 }else{
 
356 content_get(rid, &a);
357 blob_delta_apply(&a, &delta, &b);
358 isBin1 = fIncludeBinary ? 0 : looks_like_binary(&a);
359 isBin2 = fIncludeBinary ? 0 : looks_like_binary(&b);
360 if( fBaseline ){
361 diff_file_mem(&a, &b, isBin1, isBin2, zNew,
362 zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
363 }else{
364 /*Diff with file on disk using fSwapDiff=1 to show the diff in the
365 same direction as if fBaseline=1.*/
366 diff_file(&b, isBin2, zOPath, zNew, zDiffCmd,
367 zBinGlob, fIncludeBinary, diffFlags, 1);
368 }
369 blob_reset(&a);
370 blob_reset(&b);
371 }
 
372 blob_reset(&delta);
373 }
374 }
375 db_finalize(&q);
376 }
@@ -433,12 +426,15 @@
426 **
427 ** List all changes sets currently stashed. Show information about
428 ** individual files in each changeset if -v or --verbose is used.
429 **
430 ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
431 ** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS?
432 **
433 ** Show the contents of a stash as a diff against it's baseline.
434 ** With gshow and gcat, gdiff-command is used instead of internal
435 ** diff logic.
436 **
437 ** fossil stash pop
438 ** fossil stash apply ?STASHID?
439 **
440 ** Apply STASHID or the most recently create stash to the current
@@ -460,18 +456,20 @@
456 **
457 ** fossil stash diff ?STASHID? ?DIFF-OPTIONS?
458 ** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS?
459 **
460 ** Show diffs of the current working directory and what that
461 ** directory would be if STASHID were applied. With gdiff,
462 ** gdiff-command is used instead of internal diff logic.
463 **
464 ** SUMMARY:
465 ** fossil stash
466 ** fossil stash save ?-m|--comment COMMENT? ?FILES...?
467 ** fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?
468 ** fossil stash list|ls ?-v|--verbose? ?-W|--width <num>?
469 ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
470 ** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS?
471 ** fossil stash pop
472 ** fossil stash apply|goto ?STASHID?
473 ** fossil stash drop|rm ?STASHID? ?-a|--all?
474 ** fossil stash diff ?STASHID? ?DIFF-OPTIONS?
475 ** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS?
@@ -654,25 +652,30 @@
652 undo_finish();
653 }else
654 if( memcmp(zCmd, "diff", nCmd)==0
655 || memcmp(zCmd, "gdiff", nCmd)==0
656 || memcmp(zCmd, "show", nCmd)==0
657 || memcmp(zCmd, "gshow", nCmd)==0
658 || memcmp(zCmd, "cat", nCmd)==0
659 || memcmp(zCmd, "gcat", nCmd)==0
660 ){
661 const char *zDiffCmd = 0;
662 const char *zBinGlob = 0;
663 int fIncludeBinary = 0;
664 int fBaseline = 0;
665 u64 diffFlags;
666
667 if( strstr(zCmd,"show")!=0 || strstr(zCmd,"cat")!=0 ){
668 fBaseline = 1;
669 }
670 if( find_option("tk",0,0)!=0 ){
671 db_close(0);
672 diff_tk(fBaseline ? "stash show" : "stash diff", 3);
673 return;
674 }
675 if( find_option("internal","i",0)==0 ){
676 zDiffCmd = diff_command_external(zCmd[0]=='g');
677 }
678 diffFlags = diff_options();
679 if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
680 if( g.argc>4 ) usage(mprintf("%s ?STASHID? ?DIFF-OPTIONS?", zCmd));
681 if( zDiffCmd ){
682

Keyboard Shortcuts

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