Fossil SCM
Bug-fix: Function unsaved_changes() doesn't check for changes when there is an empty checkout.
Commit
f7d9413ccf470722000ecc2fa73c8056c373d127
Parent
77f53423aec1d2e…
1 file changed
+2
-4
+2
-4
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -26,17 +26,15 @@ | ||
| 26 | 26 | ** Check to see if there is an existing checkout that has been |
| 27 | 27 | ** modified. Return values: |
| 28 | 28 | ** |
| 29 | 29 | ** 0: There is an existing checkout but it is unmodified |
| 30 | 30 | ** 1: There is a modified checkout - there are unsaved changes |
| 31 | -** 2: There is no existing checkout | |
| 32 | 31 | */ |
| 33 | 32 | int unsaved_changes(unsigned int cksigFlags){ |
| 34 | 33 | int vid; |
| 35 | 34 | db_must_be_within_tree(); |
| 36 | 35 | vid = db_lget_int("checkout",0); |
| 37 | - if( vid==0 ) return 2; | |
| 38 | 36 | vfile_check_signature(vid, cksigFlags|CKSIG_ENOTFILE); |
| 39 | 37 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 40 | 38 | " OR coalesce(origname!=pathname,0)"); |
| 41 | 39 | } |
| 42 | 40 | |
| @@ -200,11 +198,11 @@ | ||
| 200 | 198 | latestFlag = find_option("latest",0,0)!=0; |
| 201 | 199 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 202 | 200 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| 203 | 201 | usage("VERSION|--latest ?--force? ?--keep?"); |
| 204 | 202 | } |
| 205 | - if( !forceFlag && unsaved_changes(0)==1 ){ | |
| 203 | + if( !forceFlag && unsaved_changes(0) ){ | |
| 206 | 204 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 207 | 205 | } |
| 208 | 206 | if( forceFlag ){ |
| 209 | 207 | db_multi_exec("DELETE FROM vfile"); |
| 210 | 208 | prior = 0; |
| @@ -288,11 +286,11 @@ | ||
| 288 | 286 | ** See also: open |
| 289 | 287 | */ |
| 290 | 288 | void close_cmd(void){ |
| 291 | 289 | int forceFlag = find_option("force","f",0)!=0; |
| 292 | 290 | db_must_be_within_tree(); |
| 293 | - if( !forceFlag && unsaved_changes(0)==1 ){ | |
| 291 | + if( !forceFlag && unsaved_changes(0) ){ | |
| 294 | 292 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 295 | 293 | } |
| 296 | 294 | if( !forceFlag |
| 297 | 295 | && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'", |
| 298 | 296 | db_name("localdb")) |
| 299 | 297 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -26,17 +26,15 @@ | |
| 26 | ** Check to see if there is an existing checkout that has been |
| 27 | ** modified. Return values: |
| 28 | ** |
| 29 | ** 0: There is an existing checkout but it is unmodified |
| 30 | ** 1: There is a modified checkout - there are unsaved changes |
| 31 | ** 2: There is no existing checkout |
| 32 | */ |
| 33 | int unsaved_changes(unsigned int cksigFlags){ |
| 34 | int vid; |
| 35 | db_must_be_within_tree(); |
| 36 | vid = db_lget_int("checkout",0); |
| 37 | if( vid==0 ) return 2; |
| 38 | vfile_check_signature(vid, cksigFlags|CKSIG_ENOTFILE); |
| 39 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 40 | " OR coalesce(origname!=pathname,0)"); |
| 41 | } |
| 42 | |
| @@ -200,11 +198,11 @@ | |
| 200 | latestFlag = find_option("latest",0,0)!=0; |
| 201 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 202 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| 203 | usage("VERSION|--latest ?--force? ?--keep?"); |
| 204 | } |
| 205 | if( !forceFlag && unsaved_changes(0)==1 ){ |
| 206 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 207 | } |
| 208 | if( forceFlag ){ |
| 209 | db_multi_exec("DELETE FROM vfile"); |
| 210 | prior = 0; |
| @@ -288,11 +286,11 @@ | |
| 288 | ** See also: open |
| 289 | */ |
| 290 | void close_cmd(void){ |
| 291 | int forceFlag = find_option("force","f",0)!=0; |
| 292 | db_must_be_within_tree(); |
| 293 | if( !forceFlag && unsaved_changes(0)==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 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -26,17 +26,15 @@ | |
| 26 | ** Check to see if there is an existing checkout that has been |
| 27 | ** modified. Return values: |
| 28 | ** |
| 29 | ** 0: There is an existing checkout but it is unmodified |
| 30 | ** 1: There is a modified checkout - there are unsaved changes |
| 31 | */ |
| 32 | int unsaved_changes(unsigned int cksigFlags){ |
| 33 | int vid; |
| 34 | db_must_be_within_tree(); |
| 35 | vid = db_lget_int("checkout",0); |
| 36 | vfile_check_signature(vid, cksigFlags|CKSIG_ENOTFILE); |
| 37 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 38 | " OR coalesce(origname!=pathname,0)"); |
| 39 | } |
| 40 | |
| @@ -200,11 +198,11 @@ | |
| 198 | latestFlag = find_option("latest",0,0)!=0; |
| 199 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 200 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| 201 | usage("VERSION|--latest ?--force? ?--keep?"); |
| 202 | } |
| 203 | if( !forceFlag && unsaved_changes(0) ){ |
| 204 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 205 | } |
| 206 | if( forceFlag ){ |
| 207 | db_multi_exec("DELETE FROM vfile"); |
| 208 | prior = 0; |
| @@ -288,11 +286,11 @@ | |
| 286 | ** See also: open |
| 287 | */ |
| 288 | void close_cmd(void){ |
| 289 | int forceFlag = find_option("force","f",0)!=0; |
| 290 | db_must_be_within_tree(); |
| 291 | if( !forceFlag && unsaved_changes(0) ){ |
| 292 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 293 | } |
| 294 | if( !forceFlag |
| 295 | && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'", |
| 296 | db_name("localdb")) |
| 297 |