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].
Commit
85a7d82e94f487ef2b61633a24aee0223dc98d671729bef08ad069b97c2f3c94
Parent
89da205267ee6e8…
1 file changed
+5
-2
+5
-2
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -581,23 +581,26 @@ | ||
| 581 | 581 | stashid = stash_create(); |
| 582 | 582 | undo_disable(); |
| 583 | 583 | if( g.argc>=2 ){ |
| 584 | 584 | int nFile = db_int(0, "SELECT count(*) FROM stashfile WHERE stashid=%d", |
| 585 | 585 | stashid); |
| 586 | - char **newArgv = fossil_malloc( sizeof(char*)*(nFile+2) ); | |
| 586 | + char **newArgv; | |
| 587 | 587 | int i = 2; |
| 588 | 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) ); | |
| 589 | 593 | db_prepare(&q,"SELECT origname FROM stashfile WHERE stashid=%d", stashid); |
| 590 | 594 | while( db_step(&q)==SQLITE_ROW ){ |
| 591 | 595 | newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0)); |
| 592 | 596 | } |
| 593 | 597 | db_finalize(&q); |
| 594 | 598 | newArgv[0] = g.argv[0]; |
| 595 | 599 | newArgv[1] = 0; |
| 596 | 600 | g.argv = newArgv; |
| 597 | 601 | g.argc = nFile+2; |
| 598 | - if( nFile==0 ) return; | |
| 599 | 602 | } |
| 600 | 603 | /* Make sure the stash has committed before running the revert, so that |
| 601 | 604 | ** we have a copy of the changes before deleting them. */ |
| 602 | 605 | db_commit_transaction(); |
| 603 | 606 | g.argv[1] = "revert"; |
| 604 | 607 |
| --- 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 |