Fossil SCM

"stash cat" worked the same as "stash diff", yet "stash cat -tk" worked the same as "stash show -tk". Make "stash cat" behave like "stash show" which matches the -tk case and also the documentation. Also add mention of DIFF-OPTIONS to the stash show|cat|diff|gdiff usage text. Remove unnecessary variable initialization in stash_get_id(), plus show the bad stash ID string rather than "0" if a non-numeric was used.

andygoth 2016-10-20 16:13 trunk
Commit 48ecfe6645a86d154db78b787879a30ecd3ad1ed
1 file changed +9 -16
+9 -16
--- src/stash.c
+++ src/stash.c
@@ -398,18 +398,18 @@
398398
** return that number. Or throw a fatal error if it is not a valid
399399
** stash number. If it is NULL, return the most recent stash or
400400
** throw an error if the stash is empty.
401401
*/
402402
static int stash_get_id(const char *zStashId){
403
- int stashid = 0;
403
+ int stashid;
404404
if( zStashId==0 ){
405405
stashid = db_int(0, "SELECT max(stashid) FROM stash");
406406
if( stashid==0 ) fossil_fatal("empty stash");
407407
}else{
408408
stashid = atoi(zStashId);
409409
if( !db_exists("SELECT 1 FROM stash WHERE stashid=%d", stashid) ){
410
- fossil_fatal("no such stash: %d\n", stashid);
410
+ fossil_fatal("no such stash: %s", zStashId);
411411
}
412412
}
413413
return stashid;
414414
}
415415
@@ -432,11 +432,11 @@
432432
** fossil stash list|ls ?-v|--verbose? ?-W|--width <num>?
433433
**
434434
** List all changes sets currently stashed. Show information about
435435
** individual files in each changeset if -v or --verbose is used.
436436
**
437
-** fossil stash show|cat ?STASHID? ?DIFF-FLAGS?
437
+** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
438438
**
439439
** Show the contents of a stash.
440440
**
441441
** fossil stash pop
442442
** fossil stash apply ?STASHID?
@@ -467,15 +467,15 @@
467467
** SUMMARY:
468468
** fossil stash
469469
** fossil stash save ?-m|--comment COMMENT? ?FILES...?
470470
** fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?
471471
** fossil stash list|ls ?-v|--verbose? ?-W|--width <num>?
472
-** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
472
+** fossil stash show ?STASHID? ?DIFF-OPTIONS?
473473
** fossil stash pop
474474
** fossil stash apply|goto ?STASHID?
475475
** fossil stash drop|rm ?STASHID? ?-a|--all?
476
-** fossil stash diff ?STASHID? ?DIFF-OPTIONS?
476
+** fossil stash diff|cat ?STASHID? ?DIFF-OPTIONS?
477477
** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS?
478478
*/
479479
void stash_cmd(void){
480480
const char *zCmd;
481481
int nCmd;
@@ -659,37 +659,30 @@
659659
|| memcmp(zCmd, "cat", 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';
664665
u64 diffFlags;
665666
666667
if( find_option("tk",0,0)!=0 ){
667668
db_close(0);
668
- switch (zCmd[0]) {
669
- case 's':
670
- case 'c':
671
- diff_tk("stash show", 3);
672
- break;
673
-
674
- default:
675
- diff_tk("stash diff", 3);
676
- }
669
+ diff_tk(fBaseline ? "stash show" : "stash diff", 3);
677670
return;
678671
}
679672
if( find_option("internal","i",0)==0 ){
680673
zDiffCmd = diff_command_external(memcmp(zCmd, "gdiff", nCmd)==0);
681674
}
682675
diffFlags = diff_options();
683676
if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
684
- if( g.argc>4 ) usage(mprintf("%s STASHID", zCmd));
677
+ if( g.argc>4 ) usage(mprintf("%s ?STASHID? ?DIFF-OPTIONS?", zCmd));
685678
if( zDiffCmd ){
686679
zBinGlob = diff_get_binary_glob();
687680
fIncludeBinary = diff_include_binary_files();
688681
}
689682
stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0);
690
- stash_diff(stashid, zDiffCmd, zBinGlob, zCmd[0]=='s', fIncludeBinary,
683
+ stash_diff(stashid, zDiffCmd, zBinGlob, fBaseline, fIncludeBinary,
691684
diffFlags);
692685
}else
693686
if( memcmp(zCmd, "help", nCmd)==0 ){
694687
g.argv[1] = "help";
695688
g.argv[2] = "stash";
696689
--- src/stash.c
+++ src/stash.c
@@ -398,18 +398,18 @@
398 ** return that number. Or throw a fatal error if it is not a valid
399 ** stash number. If it is NULL, return the most recent stash or
400 ** throw an error if the stash is empty.
401 */
402 static int stash_get_id(const char *zStashId){
403 int stashid = 0;
404 if( zStashId==0 ){
405 stashid = db_int(0, "SELECT max(stashid) FROM stash");
406 if( stashid==0 ) fossil_fatal("empty stash");
407 }else{
408 stashid = atoi(zStashId);
409 if( !db_exists("SELECT 1 FROM stash WHERE stashid=%d", stashid) ){
410 fossil_fatal("no such stash: %d\n", stashid);
411 }
412 }
413 return stashid;
414 }
415
@@ -432,11 +432,11 @@
432 ** fossil stash list|ls ?-v|--verbose? ?-W|--width <num>?
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-FLAGS?
438 **
439 ** Show the contents of a stash.
440 **
441 ** fossil stash pop
442 ** fossil stash apply ?STASHID?
@@ -467,15 +467,15 @@
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?
478 */
479 void stash_cmd(void){
480 const char *zCmd;
481 int nCmd;
@@ -659,37 +659,30 @@
659 || memcmp(zCmd, "cat", nCmd)==0
660 ){
661 const char *zDiffCmd = 0;
662 const char *zBinGlob = 0;
663 int fIncludeBinary = 0;
 
664 u64 diffFlags;
665
666 if( find_option("tk",0,0)!=0 ){
667 db_close(0);
668 switch (zCmd[0]) {
669 case 's':
670 case 'c':
671 diff_tk("stash show", 3);
672 break;
673
674 default:
675 diff_tk("stash diff", 3);
676 }
677 return;
678 }
679 if( find_option("internal","i",0)==0 ){
680 zDiffCmd = diff_command_external(memcmp(zCmd, "gdiff", nCmd)==0);
681 }
682 diffFlags = diff_options();
683 if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
684 if( g.argc>4 ) usage(mprintf("%s STASHID", zCmd));
685 if( zDiffCmd ){
686 zBinGlob = diff_get_binary_glob();
687 fIncludeBinary = diff_include_binary_files();
688 }
689 stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0);
690 stash_diff(stashid, zDiffCmd, zBinGlob, zCmd[0]=='s', fIncludeBinary,
691 diffFlags);
692 }else
693 if( memcmp(zCmd, "help", nCmd)==0 ){
694 g.argv[1] = "help";
695 g.argv[2] = "stash";
696
--- src/stash.c
+++ src/stash.c
@@ -398,18 +398,18 @@
398 ** return that number. Or throw a fatal error if it is not a valid
399 ** stash number. If it is NULL, return the most recent stash or
400 ** throw an error if the stash is empty.
401 */
402 static int stash_get_id(const char *zStashId){
403 int stashid;
404 if( zStashId==0 ){
405 stashid = db_int(0, "SELECT max(stashid) FROM stash");
406 if( stashid==0 ) fossil_fatal("empty stash");
407 }else{
408 stashid = atoi(zStashId);
409 if( !db_exists("SELECT 1 FROM stash WHERE stashid=%d", stashid) ){
410 fossil_fatal("no such stash: %s", zStashId);
411 }
412 }
413 return stashid;
414 }
415
@@ -432,11 +432,11 @@
432 ** fossil stash list|ls ?-v|--verbose? ?-W|--width <num>?
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?
@@ -467,15 +467,15 @@
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 ?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|cat ?STASHID? ?DIFF-OPTIONS?
477 ** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS?
478 */
479 void stash_cmd(void){
480 const char *zCmd;
481 int nCmd;
@@ -659,37 +659,30 @@
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 zBinGlob = diff_get_binary_glob();
680 fIncludeBinary = diff_include_binary_files();
681 }
682 stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0);
683 stash_diff(stashid, zDiffCmd, zBinGlob, fBaseline, fIncludeBinary,
684 diffFlags);
685 }else
686 if( memcmp(zCmd, "help", nCmd)==0 ){
687 g.argv[1] = "help";
688 g.argv[2] = "stash";
689

Keyboard Shortcuts

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