Index: src/stash.c ================================================================== --- src/stash.c +++ src/stash.c @@ -39,11 +39,11 @@ @ isExec BOOLEAN, -- True if file is executable @ isLink BOOLEAN, -- True if file is a symlink @ origname TEXT, -- Original filename @ newname TEXT, -- New name for file at next check-in @ delta BLOB, -- Delta from baseline. Content if rid=0 -@ PRIMARY KEY(origname, stashid) +@ PRIMARY KEY(newname, stashid) @ ); @ INSERT OR IGNORE INTO vvar(name, value) VALUES('stash-next', 1); ; /* @@ -278,10 +278,15 @@ } blob_reset(&delta); if( fossil_strcmp(zOrig,zNew)!=0 ){ undo_save(zOrig); file_delete(zOPath); + db_multi_exec( + "UPDATE vfile SET pathname='%q', origname='%q'" + " WHERE pathname='%q' %s AND vid=%d", + zNew, zOrig, zOrig, filename_collation(), vid + ); } } stash_add_files_in_sfile(vid); db_finalize(&q); if( nConflict ){ @@ -473,15 +478,30 @@ */ void stash_cmd(void){ const char *zCmd; int nCmd; int stashid = 0; + int rc; undo_capture_command_line(); db_must_be_within_tree(); db_open_config(0, 0); db_begin_transaction(); db_multi_exec(zStashInit /*works-like:""*/); + rc = db_exists("SELECT 1 FROM sqlite_master" + " WHERE name='stashfile'" + " AND sql GLOB '* PRIMARY KEY(origname, stashid)*'"); + if( rc!=0 ){ + db_multi_exec( + "CREATE TABLE localdb.stashfile_tmp AS SELECT * FROM stashfile;" + "DROP TABLE stashfile;" + ); + db_multi_exec(zStashInit /*works-like:""*/); + db_multi_exec( + "INSERT INTO stashfile SELECT * FROM stashfile_tmp;" + "DROP TABLE stashfile_tmp;" + ); + } if( g.argc<=2 ){ zCmd = "save"; }else{ zCmd = g.argv[2]; } Index: test/stash.test ================================================================== --- test/stash.test +++ test/stash.test @@ -185,15 +185,13 @@ ADDED f0 } -changes { ADDED f0 MISSING f1 EDITED f2 - MISSING f3 + RENAMED f3n } -addremove { - ADDED f3n DELETED f1 - DELETED f3 } -exists {f0 f2 f3n} -notexists {f1 f3} # Confirm there is no longer a stash saved fossil stash list test stash-2-list {[first_data_line] eq "empty stash"} @@ -311,13 +309,11 @@ UPDATE f1 UPDATE f2n } -changes { RENAMED f2n } -addremove { - ADDED f2n - DELETED f2 -} -exists {f1 f2n} -notexists {f2} -knownbugs {-changes} +} -exists {f1 f2n} -notexists {f2} ######## # fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?