Fossil SCM

Get the "stash save" command working for the case when a directory is specified as an argument.

drh 2010-12-18 22:25 trunk
Commit fc6aea52baa78b1d555dc5b308eb522b3c1de356
1 file changed +30 -9
+30 -9
--- src/stash.c
+++ src/stash.c
@@ -339,13 +339,14 @@
339339
**
340340
** Update to the baseline checkout for STASHID then apply the
341341
** changes of STASHID. Keep STASHID so that it can be reused
342342
** This command is undoable.
343343
**
344
-** fossil drop ?STASHID?
344
+** fossil drop ?STASHID? ?--all?
345345
**
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.
347348
**
348349
** fossil stash snapshot ?-m COMMENT? ?FILES...?
349350
**
350351
** Save the current changes in the working tress as a new stash
351352
** but, unlike "save", do not revert those changes.
@@ -372,13 +373,28 @@
372373
}else{
373374
zCmd = g.argv[2];
374375
}
375376
nCmd = strlen(zCmd);
376377
if( memcmp(zCmd, "save", nCmd)==0 ){
377
- stash_create();
378
+ stashid = stash_create();
378379
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";
380396
revert_cmd();
381397
}else
382398
if( memcmp(zCmd, "snapshot", nCmd)==0 ){
383399
stash_create();
384400
}else
@@ -407,16 +423,21 @@
407423
}
408424
db_finalize(&q);
409425
if( n==0 ) printf("empty stash\n");
410426
}else
411427
if( memcmp(zCmd, "drop", nCmd)==0 ){
428
+ int allFlag = find_option("all", 0, 0)!=0;
412429
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
+ }
418439
}else
419440
if( memcmp(zCmd, "pop", nCmd)==0 ){
420441
if( g.argc>3 ) usage("stash pop");
421442
stashid = stash_get_id(0);
422443
undo_begin();
423444
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button