Fossil SCM
Get the "stash save" command working for the case when a directory is specified as an argument.
Commit
fc6aea52baa78b1d555dc5b308eb522b3c1de356
Parent
12a2a5eaf20f2d2…
1 file changed
+30
-9
+30
-9
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -339,13 +339,14 @@ | ||
| 339 | 339 | ** |
| 340 | 340 | ** Update to the baseline checkout for STASHID then apply the |
| 341 | 341 | ** changes of STASHID. Keep STASHID so that it can be reused |
| 342 | 342 | ** This command is undoable. |
| 343 | 343 | ** |
| 344 | -** fossil drop ?STASHID? | |
| 344 | +** fossil drop ?STASHID? ?--all? | |
| 345 | 345 | ** |
| 346 | -** Forget everything about STASHID. This command is undoable. | |
| 346 | +** Forget everything about STASHID. Forget the whole stash if the | |
| 347 | +** --all flag is used. Individual drops are undoable but --all is not. | |
| 347 | 348 | ** |
| 348 | 349 | ** fossil stash snapshot ?-m COMMENT? ?FILES...? |
| 349 | 350 | ** |
| 350 | 351 | ** Save the current changes in the working tress as a new stash |
| 351 | 352 | ** but, unlike "save", do not revert those changes. |
| @@ -372,13 +373,28 @@ | ||
| 372 | 373 | }else{ |
| 373 | 374 | zCmd = g.argv[2]; |
| 374 | 375 | } |
| 375 | 376 | nCmd = strlen(zCmd); |
| 376 | 377 | if( memcmp(zCmd, "save", nCmd)==0 ){ |
| 377 | - stash_create(); | |
| 378 | + stashid = stash_create(); | |
| 378 | 379 | undo_disable(); |
| 379 | - g.argc = 2; | |
| 380 | + if( g.argc>=3 ){ | |
| 381 | + int nFile = db_int(0, "SELECT count(*) FROM stashfile WHERE stashid=%d", | |
| 382 | + stashid); | |
| 383 | + char **newArgv = fossil_malloc( sizeof(char*)*(nFile+2) ); | |
| 384 | + int i = 2; | |
| 385 | + Stmt q; | |
| 386 | + db_prepare(&q,"SELECT origname FROM stashfile WHERE stashid=%d", stashid); | |
| 387 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 388 | + newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0)); | |
| 389 | + } | |
| 390 | + db_finalize(&q); | |
| 391 | + newArgv[0] = g.argv[0]; | |
| 392 | + g.argv = newArgv; | |
| 393 | + g.argc = nFile+2; | |
| 394 | + } | |
| 395 | + g.argv[1] = "revert"; | |
| 380 | 396 | revert_cmd(); |
| 381 | 397 | }else |
| 382 | 398 | if( memcmp(zCmd, "snapshot", nCmd)==0 ){ |
| 383 | 399 | stash_create(); |
| 384 | 400 | }else |
| @@ -407,16 +423,21 @@ | ||
| 407 | 423 | } |
| 408 | 424 | db_finalize(&q); |
| 409 | 425 | if( n==0 ) printf("empty stash\n"); |
| 410 | 426 | }else |
| 411 | 427 | if( memcmp(zCmd, "drop", nCmd)==0 ){ |
| 428 | + int allFlag = find_option("all", 0, 0)!=0; | |
| 412 | 429 | if( g.argc>4 ) usage("stash apply STASHID"); |
| 413 | - stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0); | |
| 414 | - undo_begin(); | |
| 415 | - undo_save_stash(stashid); | |
| 416 | - stash_drop(stashid); | |
| 417 | - undo_finish(); | |
| 430 | + if( allFlag ){ | |
| 431 | + db_multi_exec("DELETE FROM stash; DELETE FROM stashfile;"); | |
| 432 | + }else{ | |
| 433 | + stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0); | |
| 434 | + undo_begin(); | |
| 435 | + undo_save_stash(stashid); | |
| 436 | + stash_drop(stashid); | |
| 437 | + undo_finish(); | |
| 438 | + } | |
| 418 | 439 | }else |
| 419 | 440 | if( memcmp(zCmd, "pop", nCmd)==0 ){ |
| 420 | 441 | if( g.argc>3 ) usage("stash pop"); |
| 421 | 442 | stashid = stash_get_id(0); |
| 422 | 443 | undo_begin(); |
| 423 | 444 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -339,13 +339,14 @@ | |
| 339 | ** |
| 340 | ** Update to the baseline checkout for STASHID then apply the |
| 341 | ** changes of STASHID. Keep STASHID so that it can be reused |
| 342 | ** This command is undoable. |
| 343 | ** |
| 344 | ** fossil drop ?STASHID? |
| 345 | ** |
| 346 | ** Forget everything about STASHID. This command is undoable. |
| 347 | ** |
| 348 | ** fossil stash snapshot ?-m COMMENT? ?FILES...? |
| 349 | ** |
| 350 | ** Save the current changes in the working tress as a new stash |
| 351 | ** but, unlike "save", do not revert those changes. |
| @@ -372,13 +373,28 @@ | |
| 372 | }else{ |
| 373 | zCmd = g.argv[2]; |
| 374 | } |
| 375 | nCmd = strlen(zCmd); |
| 376 | if( memcmp(zCmd, "save", nCmd)==0 ){ |
| 377 | stash_create(); |
| 378 | undo_disable(); |
| 379 | g.argc = 2; |
| 380 | revert_cmd(); |
| 381 | }else |
| 382 | if( memcmp(zCmd, "snapshot", nCmd)==0 ){ |
| 383 | stash_create(); |
| 384 | }else |
| @@ -407,16 +423,21 @@ | |
| 407 | } |
| 408 | db_finalize(&q); |
| 409 | if( n==0 ) printf("empty stash\n"); |
| 410 | }else |
| 411 | if( memcmp(zCmd, "drop", nCmd)==0 ){ |
| 412 | if( g.argc>4 ) usage("stash apply STASHID"); |
| 413 | stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0); |
| 414 | undo_begin(); |
| 415 | undo_save_stash(stashid); |
| 416 | stash_drop(stashid); |
| 417 | undo_finish(); |
| 418 | }else |
| 419 | if( memcmp(zCmd, "pop", nCmd)==0 ){ |
| 420 | if( g.argc>3 ) usage("stash pop"); |
| 421 | stashid = stash_get_id(0); |
| 422 | undo_begin(); |
| 423 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -339,13 +339,14 @@ | |
| 339 | ** |
| 340 | ** Update to the baseline checkout for STASHID then apply the |
| 341 | ** changes of STASHID. Keep STASHID so that it can be reused |
| 342 | ** This command is undoable. |
| 343 | ** |
| 344 | ** fossil drop ?STASHID? ?--all? |
| 345 | ** |
| 346 | ** Forget everything about STASHID. Forget the whole stash if the |
| 347 | ** --all flag is used. Individual drops are undoable but --all is not. |
| 348 | ** |
| 349 | ** fossil stash snapshot ?-m COMMENT? ?FILES...? |
| 350 | ** |
| 351 | ** Save the current changes in the working tress as a new stash |
| 352 | ** but, unlike "save", do not revert those changes. |
| @@ -372,13 +373,28 @@ | |
| 373 | }else{ |
| 374 | zCmd = g.argv[2]; |
| 375 | } |
| 376 | nCmd = strlen(zCmd); |
| 377 | if( memcmp(zCmd, "save", nCmd)==0 ){ |
| 378 | stashid = stash_create(); |
| 379 | undo_disable(); |
| 380 | if( g.argc>=3 ){ |
| 381 | int nFile = db_int(0, "SELECT count(*) FROM stashfile WHERE stashid=%d", |
| 382 | stashid); |
| 383 | char **newArgv = fossil_malloc( sizeof(char*)*(nFile+2) ); |
| 384 | int i = 2; |
| 385 | Stmt q; |
| 386 | db_prepare(&q,"SELECT origname FROM stashfile WHERE stashid=%d", stashid); |
| 387 | while( db_step(&q)==SQLITE_ROW ){ |
| 388 | newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0)); |
| 389 | } |
| 390 | db_finalize(&q); |
| 391 | newArgv[0] = g.argv[0]; |
| 392 | g.argv = newArgv; |
| 393 | g.argc = nFile+2; |
| 394 | } |
| 395 | g.argv[1] = "revert"; |
| 396 | revert_cmd(); |
| 397 | }else |
| 398 | if( memcmp(zCmd, "snapshot", nCmd)==0 ){ |
| 399 | stash_create(); |
| 400 | }else |
| @@ -407,16 +423,21 @@ | |
| 423 | } |
| 424 | db_finalize(&q); |
| 425 | if( n==0 ) printf("empty stash\n"); |
| 426 | }else |
| 427 | if( memcmp(zCmd, "drop", nCmd)==0 ){ |
| 428 | int allFlag = find_option("all", 0, 0)!=0; |
| 429 | if( g.argc>4 ) usage("stash apply STASHID"); |
| 430 | if( allFlag ){ |
| 431 | db_multi_exec("DELETE FROM stash; DELETE FROM stashfile;"); |
| 432 | }else{ |
| 433 | stashid = stash_get_id(g.argc==4 ? g.argv[3] : 0); |
| 434 | undo_begin(); |
| 435 | undo_save_stash(stashid); |
| 436 | stash_drop(stashid); |
| 437 | undo_finish(); |
| 438 | } |
| 439 | }else |
| 440 | if( memcmp(zCmd, "pop", nCmd)==0 ){ |
| 441 | if( g.argc>3 ) usage("stash pop"); |
| 442 | stashid = stash_get_id(0); |
| 443 | undo_begin(); |
| 444 |