Fossil SCM

branch, start committing hacking that will hopefully yield fix to this problem: one is allowed to checkout "artifacts" that should not be checkout-able (ie: changes to tickets); trying to check this out is permitted, but results in a segfault

bch 2009-04-19 05:48 UTC trunk
Commit 4fff36610997f7f3b222d981b30d9ae99f177e5d
1 file changed +33
--- src/checkout.c
+++ src/checkout.c
@@ -43,10 +43,40 @@
4343
if( vid==0 ) return 2;
4444
vfile_check_signature(vid);
4545
return db_exists("SELECT 1 FROM vfile WHERE chnged"
4646
" OR coalesce(origname!=pathname,0)");
4747
}
48
+
49
+/*
50
+** Check to see if the requested co is in fact "checkout-able"
51
+** Return values:
52
+** 0: Not checkout-able (does not exist, or is not an on-disk artifact)
53
+** 1: Is checkout-able.
54
+*/
55
+int checkoutable(const char *zName){
56
+ int rc=1; /* assuming is checkout-able */
57
+ Blob uuid;
58
+ const char *rid=(char *)NULL;
59
+ Stmt q; // db query
60
+ char *zSQL; //build-up sql
61
+
62
+ // zSQL = mprintf();
63
+
64
+ // [create sql statement]
65
+ // db_prepare(&q,sqlstmt);
66
+
67
+ blob_init(&uuid, zName, -1);
68
+ if( name_to_uuid(&uuid, 1) ){
69
+ fossil_panic(g.zErrMsg);
70
+ }
71
+
72
+ /* nParent=db_text(0,"select rid from blob where uuid=%s",uuid.nameofobj); */
73
+
74
+ /* int nParent = db_column_int(q, somenum); */
75
+ return rc;
76
+}
77
+
4878
4979
/*
5080
** Undo the current check-out. Unlink all files from the disk.
5181
** Clear the VFILE table.
5282
*/
@@ -157,10 +187,13 @@
157187
noWrite = find_option("dontwrite",0,0)!=0;
158188
if( g.argc!=3 ) usage("?--force? VERSION");
159189
if( !forceFlag && unsaved_changes()==1 ){
160190
fossil_fatal("there are unsaved changes in the current checkout");
161191
}
192
+ if(!checkoutable()){
193
+ fossil_fatal("the VERSION you requested is not a checkout-able artifact");
194
+ }
162195
if( forceFlag ){
163196
db_multi_exec("DELETE FROM vfile");
164197
prior = 0;
165198
}else{
166199
prior = db_lget_int("checkout",0);
167200
--- src/checkout.c
+++ src/checkout.c
@@ -43,10 +43,40 @@
43 if( vid==0 ) return 2;
44 vfile_check_signature(vid);
45 return db_exists("SELECT 1 FROM vfile WHERE chnged"
46 " OR coalesce(origname!=pathname,0)");
47 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
49 /*
50 ** Undo the current check-out. Unlink all files from the disk.
51 ** Clear the VFILE table.
52 */
@@ -157,10 +187,13 @@
157 noWrite = find_option("dontwrite",0,0)!=0;
158 if( g.argc!=3 ) usage("?--force? VERSION");
159 if( !forceFlag && unsaved_changes()==1 ){
160 fossil_fatal("there are unsaved changes in the current checkout");
161 }
 
 
 
162 if( forceFlag ){
163 db_multi_exec("DELETE FROM vfile");
164 prior = 0;
165 }else{
166 prior = db_lget_int("checkout",0);
167
--- src/checkout.c
+++ src/checkout.c
@@ -43,10 +43,40 @@
43 if( vid==0 ) return 2;
44 vfile_check_signature(vid);
45 return db_exists("SELECT 1 FROM vfile WHERE chnged"
46 " OR coalesce(origname!=pathname,0)");
47 }
48
49 /*
50 ** Check to see if the requested co is in fact "checkout-able"
51 ** Return values:
52 ** 0: Not checkout-able (does not exist, or is not an on-disk artifact)
53 ** 1: Is checkout-able.
54 */
55 int checkoutable(const char *zName){
56 int rc=1; /* assuming is checkout-able */
57 Blob uuid;
58 const char *rid=(char *)NULL;
59 Stmt q; // db query
60 char *zSQL; //build-up sql
61
62 // zSQL = mprintf();
63
64 // [create sql statement]
65 // db_prepare(&q,sqlstmt);
66
67 blob_init(&uuid, zName, -1);
68 if( name_to_uuid(&uuid, 1) ){
69 fossil_panic(g.zErrMsg);
70 }
71
72 /* nParent=db_text(0,"select rid from blob where uuid=%s",uuid.nameofobj); */
73
74 /* int nParent = db_column_int(q, somenum); */
75 return rc;
76 }
77
78
79 /*
80 ** Undo the current check-out. Unlink all files from the disk.
81 ** Clear the VFILE table.
82 */
@@ -157,10 +187,13 @@
187 noWrite = find_option("dontwrite",0,0)!=0;
188 if( g.argc!=3 ) usage("?--force? VERSION");
189 if( !forceFlag && unsaved_changes()==1 ){
190 fossil_fatal("there are unsaved changes in the current checkout");
191 }
192 if(!checkoutable()){
193 fossil_fatal("the VERSION you requested is not a checkout-able artifact");
194 }
195 if( forceFlag ){
196 db_multi_exec("DELETE FROM vfile");
197 prior = 0;
198 }else{
199 prior = db_lget_int("checkout",0);
200

Keyboard Shortcuts

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