Fossil SCM
Refuse to close a check-out if the stash is non-empty and the -f flag is omitted.
Commit
c6aedbd0bd48ad7b5df07da49895e5fb47e4707b
Parent
f94f3e3a79992d2…
1 file changed
+8
-1
+8
-1
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -278,11 +278,11 @@ | ||
| 278 | 278 | ** |
| 279 | 279 | ** Usage: %fossil close ?OPTIONS? |
| 280 | 280 | ** |
| 281 | 281 | ** The opposite of "open". Close the current database connection. |
| 282 | 282 | ** Require a -f or --force flag if there are unsaved changed in the |
| 283 | -** current check-out. | |
| 283 | +** current check-out or if there is non-empty stash. | |
| 284 | 284 | ** |
| 285 | 285 | ** Options: |
| 286 | 286 | ** --force|-f necessary to close a check out with uncommitted changes |
| 287 | 287 | ** |
| 288 | 288 | ** See also: open |
| @@ -291,12 +291,19 @@ | ||
| 291 | 291 | int forceFlag = find_option("force","f",0)!=0; |
| 292 | 292 | db_must_be_within_tree(); |
| 293 | 293 | if( !forceFlag && unsaved_changes()==1 ){ |
| 294 | 294 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 295 | 295 | } |
| 296 | + if( !forceFlag | |
| 297 | + && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'", | |
| 298 | + db_name("localdb")) | |
| 299 | + && db_exists("SELECT 1 FROM %s.stash", db_name("localdb")) | |
| 300 | + ){ | |
| 301 | + fossil_fatal("closing the checkout will delete your stash"); | |
| 302 | + } | |
| 296 | 303 | if( db_is_writeable("repository") ){ |
| 297 | 304 | db_multi_exec("DELETE FROM config WHERE name='ckout:%q'", g.zLocalRoot); |
| 298 | 305 | } |
| 299 | 306 | unlink_local_database(1); |
| 300 | 307 | db_close(1); |
| 301 | 308 | unlink_local_database(0); |
| 302 | 309 | } |
| 303 | 310 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -278,11 +278,11 @@ | |
| 278 | ** |
| 279 | ** Usage: %fossil close ?OPTIONS? |
| 280 | ** |
| 281 | ** The opposite of "open". Close the current database connection. |
| 282 | ** Require a -f or --force flag if there are unsaved changed in the |
| 283 | ** current check-out. |
| 284 | ** |
| 285 | ** Options: |
| 286 | ** --force|-f necessary to close a check out with uncommitted changes |
| 287 | ** |
| 288 | ** See also: open |
| @@ -291,12 +291,19 @@ | |
| 291 | int forceFlag = find_option("force","f",0)!=0; |
| 292 | db_must_be_within_tree(); |
| 293 | if( !forceFlag && unsaved_changes()==1 ){ |
| 294 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 295 | } |
| 296 | if( db_is_writeable("repository") ){ |
| 297 | db_multi_exec("DELETE FROM config WHERE name='ckout:%q'", g.zLocalRoot); |
| 298 | } |
| 299 | unlink_local_database(1); |
| 300 | db_close(1); |
| 301 | unlink_local_database(0); |
| 302 | } |
| 303 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -278,11 +278,11 @@ | |
| 278 | ** |
| 279 | ** Usage: %fossil close ?OPTIONS? |
| 280 | ** |
| 281 | ** The opposite of "open". Close the current database connection. |
| 282 | ** Require a -f or --force flag if there are unsaved changed in the |
| 283 | ** current check-out or if there is non-empty stash. |
| 284 | ** |
| 285 | ** Options: |
| 286 | ** --force|-f necessary to close a check out with uncommitted changes |
| 287 | ** |
| 288 | ** See also: open |
| @@ -291,12 +291,19 @@ | |
| 291 | int forceFlag = find_option("force","f",0)!=0; |
| 292 | db_must_be_within_tree(); |
| 293 | if( !forceFlag && unsaved_changes()==1 ){ |
| 294 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 295 | } |
| 296 | if( !forceFlag |
| 297 | && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'", |
| 298 | db_name("localdb")) |
| 299 | && db_exists("SELECT 1 FROM %s.stash", db_name("localdb")) |
| 300 | ){ |
| 301 | fossil_fatal("closing the checkout will delete your stash"); |
| 302 | } |
| 303 | if( db_is_writeable("repository") ){ |
| 304 | db_multi_exec("DELETE FROM config WHERE name='ckout:%q'", g.zLocalRoot); |
| 305 | } |
| 306 | unlink_local_database(1); |
| 307 | db_close(1); |
| 308 | unlink_local_database(0); |
| 309 | } |
| 310 |