Fossil SCM

Bug-fix: Function unsaved_changes() doesn't check for changes when there is an empty checkout.

jan.nijtmans 2014-05-09 07:34 trunk
Commit f7d9413ccf470722000ecc2fa73c8056c373d127
1 file changed +2 -4
+2 -4
--- src/checkout.c
+++ src/checkout.c
@@ -26,17 +26,15 @@
2626
** Check to see if there is an existing checkout that has been
2727
** modified. Return values:
2828
**
2929
** 0: There is an existing checkout but it is unmodified
3030
** 1: There is a modified checkout - there are unsaved changes
31
-** 2: There is no existing checkout
3231
*/
3332
int unsaved_changes(unsigned int cksigFlags){
3433
int vid;
3534
db_must_be_within_tree();
3635
vid = db_lget_int("checkout",0);
37
- if( vid==0 ) return 2;
3836
vfile_check_signature(vid, cksigFlags|CKSIG_ENOTFILE);
3937
return db_exists("SELECT 1 FROM vfile WHERE chnged"
4038
" OR coalesce(origname!=pathname,0)");
4139
}
4240
@@ -200,11 +198,11 @@
200198
latestFlag = find_option("latest",0,0)!=0;
201199
promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
202200
if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
203201
usage("VERSION|--latest ?--force? ?--keep?");
204202
}
205
- if( !forceFlag && unsaved_changes(0)==1 ){
203
+ if( !forceFlag && unsaved_changes(0) ){
206204
fossil_fatal("there are unsaved changes in the current checkout");
207205
}
208206
if( forceFlag ){
209207
db_multi_exec("DELETE FROM vfile");
210208
prior = 0;
@@ -288,11 +286,11 @@
288286
** See also: open
289287
*/
290288
void close_cmd(void){
291289
int forceFlag = find_option("force","f",0)!=0;
292290
db_must_be_within_tree();
293
- if( !forceFlag && unsaved_changes(0)==1 ){
291
+ if( !forceFlag && unsaved_changes(0) ){
294292
fossil_fatal("there are unsaved changes in the current checkout");
295293
}
296294
if( !forceFlag
297295
&& db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'",
298296
db_name("localdb"))
299297
--- 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

Keyboard Shortcuts

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