Index: src/add.c ================================================================== --- src/add.c +++ src/add.c @@ -692,5 +692,13 @@ mv_one_file(vid, zFrom, zTo); } db_finalize(&q); db_end_transaction(0); } + +/* +** Function for stash_apply to be able to restore a file and indicate +** newly ADDED state. +*/ +int stash_add_files_in_sfile(int vid){ + return add_files_in_sfile(vid); +} Index: src/stash.c ================================================================== --- src/stash.c +++ src/stash.c @@ -199,16 +199,20 @@ /* ** Apply a stash to the current check-out. */ static void stash_apply(int stashid, int nConflict){ + int vid; Stmt q; db_prepare(&q, "SELECT rid, isRemoved, isExec, isLink, origname, newname, delta" " FROM stashfile WHERE stashid=%d", stashid ); + vid = db_lget_int("checkout",0); + db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)", + filename_collation()); while( db_step(&q)==SQLITE_ROW ){ int rid = db_column_int(&q, 0); int isRemoved = db_column_int(&q, 1); int isExec = db_column_int(&q, 2); int isLink = db_column_int(&q, 3); @@ -218,14 +222,14 @@ char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew); Blob delta; undo_save(zNew); blob_zero(&delta); if( rid==0 ){ + db_multi_exec("INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", zNew); db_ephemeral_blob(&q, 6, &delta); blob_write_to_file(&delta, zNPath); file_wd_setexe(zNPath, isExec); - fossil_print("ADD %s\n", zNew); }else if( isRemoved ){ fossil_print("DELETE %s\n", zOrig); file_delete(zOPath); }else{ Blob a, b, out, disk; @@ -276,10 +280,11 @@ if( fossil_strcmp(zOrig,zNew)!=0 ){ undo_save(zOrig); file_delete(zOPath); } } + stash_add_files_in_sfile(vid); db_finalize(&q); if( nConflict ){ fossil_print( "WARNING: %d merge conflicts - see messages above for details.\n", nConflict);