Fossil SCM
Fix the stash so that it remembers added files and readds them when the stash is applied.
Commit
db052aa4c6bc6c642c88edf714d086505945878e
Parent
1c9e0233827299e…
2 files changed
+8
+6
-1
+8
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -692,5 +692,13 @@ | ||
| 692 | 692 | mv_one_file(vid, zFrom, zTo); |
| 693 | 693 | } |
| 694 | 694 | db_finalize(&q); |
| 695 | 695 | db_end_transaction(0); |
| 696 | 696 | } |
| 697 | + | |
| 698 | +/* | |
| 699 | +** Function for stash_apply to be able to restore a file and indicate | |
| 700 | +** newly ADDED state. | |
| 701 | +*/ | |
| 702 | +int stash_add_files_in_sfile(int vid){ | |
| 703 | + return add_files_in_sfile(vid); | |
| 704 | +} | |
| 697 | 705 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -692,5 +692,13 @@ | |
| 692 | mv_one_file(vid, zFrom, zTo); |
| 693 | } |
| 694 | db_finalize(&q); |
| 695 | db_end_transaction(0); |
| 696 | } |
| 697 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -692,5 +692,13 @@ | |
| 692 | mv_one_file(vid, zFrom, zTo); |
| 693 | } |
| 694 | db_finalize(&q); |
| 695 | db_end_transaction(0); |
| 696 | } |
| 697 | |
| 698 | /* |
| 699 | ** Function for stash_apply to be able to restore a file and indicate |
| 700 | ** newly ADDED state. |
| 701 | */ |
| 702 | int stash_add_files_in_sfile(int vid){ |
| 703 | return add_files_in_sfile(vid); |
| 704 | } |
| 705 |
+6
-1
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -199,16 +199,20 @@ | ||
| 199 | 199 | |
| 200 | 200 | /* |
| 201 | 201 | ** Apply a stash to the current check-out. |
| 202 | 202 | */ |
| 203 | 203 | static void stash_apply(int stashid, int nConflict){ |
| 204 | + int vid; | |
| 204 | 205 | Stmt q; |
| 205 | 206 | db_prepare(&q, |
| 206 | 207 | "SELECT rid, isRemoved, isExec, isLink, origname, newname, delta" |
| 207 | 208 | " FROM stashfile WHERE stashid=%d", |
| 208 | 209 | stashid |
| 209 | 210 | ); |
| 211 | + vid = db_lget_int("checkout",0); | |
| 212 | + db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)", | |
| 213 | + filename_collation()); | |
| 210 | 214 | while( db_step(&q)==SQLITE_ROW ){ |
| 211 | 215 | int rid = db_column_int(&q, 0); |
| 212 | 216 | int isRemoved = db_column_int(&q, 1); |
| 213 | 217 | int isExec = db_column_int(&q, 2); |
| 214 | 218 | int isLink = db_column_int(&q, 3); |
| @@ -218,14 +222,14 @@ | ||
| 218 | 222 | char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew); |
| 219 | 223 | Blob delta; |
| 220 | 224 | undo_save(zNew); |
| 221 | 225 | blob_zero(&delta); |
| 222 | 226 | if( rid==0 ){ |
| 227 | + db_multi_exec("INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", zNew); | |
| 223 | 228 | db_ephemeral_blob(&q, 6, &delta); |
| 224 | 229 | blob_write_to_file(&delta, zNPath); |
| 225 | 230 | file_wd_setexe(zNPath, isExec); |
| 226 | - fossil_print("ADD %s\n", zNew); | |
| 227 | 231 | }else if( isRemoved ){ |
| 228 | 232 | fossil_print("DELETE %s\n", zOrig); |
| 229 | 233 | file_delete(zOPath); |
| 230 | 234 | }else{ |
| 231 | 235 | Blob a, b, out, disk; |
| @@ -276,10 +280,11 @@ | ||
| 276 | 280 | if( fossil_strcmp(zOrig,zNew)!=0 ){ |
| 277 | 281 | undo_save(zOrig); |
| 278 | 282 | file_delete(zOPath); |
| 279 | 283 | } |
| 280 | 284 | } |
| 285 | + stash_add_files_in_sfile(vid); | |
| 281 | 286 | db_finalize(&q); |
| 282 | 287 | if( nConflict ){ |
| 283 | 288 | fossil_print( |
| 284 | 289 | "WARNING: %d merge conflicts - see messages above for details.\n", |
| 285 | 290 | nConflict); |
| 286 | 291 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -199,16 +199,20 @@ | |
| 199 | |
| 200 | /* |
| 201 | ** Apply a stash to the current check-out. |
| 202 | */ |
| 203 | static void stash_apply(int stashid, int nConflict){ |
| 204 | Stmt q; |
| 205 | db_prepare(&q, |
| 206 | "SELECT rid, isRemoved, isExec, isLink, origname, newname, delta" |
| 207 | " FROM stashfile WHERE stashid=%d", |
| 208 | stashid |
| 209 | ); |
| 210 | while( db_step(&q)==SQLITE_ROW ){ |
| 211 | int rid = db_column_int(&q, 0); |
| 212 | int isRemoved = db_column_int(&q, 1); |
| 213 | int isExec = db_column_int(&q, 2); |
| 214 | int isLink = db_column_int(&q, 3); |
| @@ -218,14 +222,14 @@ | |
| 218 | char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew); |
| 219 | Blob delta; |
| 220 | undo_save(zNew); |
| 221 | blob_zero(&delta); |
| 222 | if( rid==0 ){ |
| 223 | db_ephemeral_blob(&q, 6, &delta); |
| 224 | blob_write_to_file(&delta, zNPath); |
| 225 | file_wd_setexe(zNPath, isExec); |
| 226 | fossil_print("ADD %s\n", zNew); |
| 227 | }else if( isRemoved ){ |
| 228 | fossil_print("DELETE %s\n", zOrig); |
| 229 | file_delete(zOPath); |
| 230 | }else{ |
| 231 | Blob a, b, out, disk; |
| @@ -276,10 +280,11 @@ | |
| 276 | if( fossil_strcmp(zOrig,zNew)!=0 ){ |
| 277 | undo_save(zOrig); |
| 278 | file_delete(zOPath); |
| 279 | } |
| 280 | } |
| 281 | db_finalize(&q); |
| 282 | if( nConflict ){ |
| 283 | fossil_print( |
| 284 | "WARNING: %d merge conflicts - see messages above for details.\n", |
| 285 | nConflict); |
| 286 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -199,16 +199,20 @@ | |
| 199 | |
| 200 | /* |
| 201 | ** Apply a stash to the current check-out. |
| 202 | */ |
| 203 | static void stash_apply(int stashid, int nConflict){ |
| 204 | int vid; |
| 205 | Stmt q; |
| 206 | db_prepare(&q, |
| 207 | "SELECT rid, isRemoved, isExec, isLink, origname, newname, delta" |
| 208 | " FROM stashfile WHERE stashid=%d", |
| 209 | stashid |
| 210 | ); |
| 211 | vid = db_lget_int("checkout",0); |
| 212 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)", |
| 213 | filename_collation()); |
| 214 | while( db_step(&q)==SQLITE_ROW ){ |
| 215 | int rid = db_column_int(&q, 0); |
| 216 | int isRemoved = db_column_int(&q, 1); |
| 217 | int isExec = db_column_int(&q, 2); |
| 218 | int isLink = db_column_int(&q, 3); |
| @@ -218,14 +222,14 @@ | |
| 222 | char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew); |
| 223 | Blob delta; |
| 224 | undo_save(zNew); |
| 225 | blob_zero(&delta); |
| 226 | if( rid==0 ){ |
| 227 | db_multi_exec("INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", zNew); |
| 228 | db_ephemeral_blob(&q, 6, &delta); |
| 229 | blob_write_to_file(&delta, zNPath); |
| 230 | file_wd_setexe(zNPath, isExec); |
| 231 | }else if( isRemoved ){ |
| 232 | fossil_print("DELETE %s\n", zOrig); |
| 233 | file_delete(zOPath); |
| 234 | }else{ |
| 235 | Blob a, b, out, disk; |
| @@ -276,10 +280,11 @@ | |
| 280 | if( fossil_strcmp(zOrig,zNew)!=0 ){ |
| 281 | undo_save(zOrig); |
| 282 | file_delete(zOPath); |
| 283 | } |
| 284 | } |
| 285 | stash_add_files_in_sfile(vid); |
| 286 | db_finalize(&q); |
| 287 | if( nConflict ){ |
| 288 | fossil_print( |
| 289 | "WARNING: %d merge conflicts - see messages above for details.\n", |
| 290 | nConflict); |
| 291 |