Fossil SCM

When (stash save) is given no valid file names, fail loudly rather than silently, as the latter emits only a message about an uncommitted transaction. Reported in [forum:747f0c32aa].

stephan 2024-05-02 10:03 trunk
Commit 85a7d82e94f487ef2b61633a24aee0223dc98d671729bef08ad069b97c2f3c94
1 file changed +5 -2
+5 -2
--- src/stash.c
+++ src/stash.c
@@ -581,23 +581,26 @@
581581
stashid = stash_create();
582582
undo_disable();
583583
if( g.argc>=2 ){
584584
int nFile = db_int(0, "SELECT count(*) FROM stashfile WHERE stashid=%d",
585585
stashid);
586
- char **newArgv = fossil_malloc( sizeof(char*)*(nFile+2) );
586
+ char **newArgv;
587587
int i = 2;
588588
Stmt q;
589
+ if( nFile==0 ){
590
+ fossil_fatal("No modified files match the provided pattern.");
591
+ }
592
+ newArgv = fossil_malloc( sizeof(char*)*(nFile+2) );
589593
db_prepare(&q,"SELECT origname FROM stashfile WHERE stashid=%d", stashid);
590594
while( db_step(&q)==SQLITE_ROW ){
591595
newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0));
592596
}
593597
db_finalize(&q);
594598
newArgv[0] = g.argv[0];
595599
newArgv[1] = 0;
596600
g.argv = newArgv;
597601
g.argc = nFile+2;
598
- if( nFile==0 ) return;
599602
}
600603
/* Make sure the stash has committed before running the revert, so that
601604
** we have a copy of the changes before deleting them. */
602605
db_commit_transaction();
603606
g.argv[1] = "revert";
604607
--- src/stash.c
+++ src/stash.c
@@ -581,23 +581,26 @@
581 stashid = stash_create();
582 undo_disable();
583 if( g.argc>=2 ){
584 int nFile = db_int(0, "SELECT count(*) FROM stashfile WHERE stashid=%d",
585 stashid);
586 char **newArgv = fossil_malloc( sizeof(char*)*(nFile+2) );
587 int i = 2;
588 Stmt q;
 
 
 
 
589 db_prepare(&q,"SELECT origname FROM stashfile WHERE stashid=%d", stashid);
590 while( db_step(&q)==SQLITE_ROW ){
591 newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0));
592 }
593 db_finalize(&q);
594 newArgv[0] = g.argv[0];
595 newArgv[1] = 0;
596 g.argv = newArgv;
597 g.argc = nFile+2;
598 if( nFile==0 ) return;
599 }
600 /* Make sure the stash has committed before running the revert, so that
601 ** we have a copy of the changes before deleting them. */
602 db_commit_transaction();
603 g.argv[1] = "revert";
604
--- src/stash.c
+++ src/stash.c
@@ -581,23 +581,26 @@
581 stashid = stash_create();
582 undo_disable();
583 if( g.argc>=2 ){
584 int nFile = db_int(0, "SELECT count(*) FROM stashfile WHERE stashid=%d",
585 stashid);
586 char **newArgv;
587 int i = 2;
588 Stmt q;
589 if( nFile==0 ){
590 fossil_fatal("No modified files match the provided pattern.");
591 }
592 newArgv = fossil_malloc( sizeof(char*)*(nFile+2) );
593 db_prepare(&q,"SELECT origname FROM stashfile WHERE stashid=%d", stashid);
594 while( db_step(&q)==SQLITE_ROW ){
595 newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0));
596 }
597 db_finalize(&q);
598 newArgv[0] = g.argv[0];
599 newArgv[1] = 0;
600 g.argv = newArgv;
601 g.argc = nFile+2;
 
602 }
603 /* Make sure the stash has committed before running the revert, so that
604 ** we have a copy of the changes before deleting them. */
605 db_commit_transaction();
606 g.argv[1] = "revert";
607

Keyboard Shortcuts

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