Differences From:
File
src/checkout.c
part of check-in
[a89b436bc9]
- Make command-alias for 'checkout': co. This command could -not- have been used previously as a shortcut, as it would be ambiguous becuase of 'commit' and 'configuration'. A natural mate for 'ci'.
by
bharder on
2009-02-11 05:00:02.
[view]
To:
File
src/checkout.c
part of check-in
[4fff366109]
- 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
by
bch on
2009-04-19 05:48:45.
[view]
@@ -46,8 +46,38 @@
" OR coalesce(origname!=pathname,0)");
}
/*
+** Check to see if the requested co is in fact "checkout-able"
+** Return values:
+** 0: Not checkout-able (does not exist, or is not an on-disk artifact)
+** 1: Is checkout-able.
+*/
+int checkoutable(const char *zName){
+ int rc=1; /* assuming is checkout-able */
+ Blob uuid;
+ const char *rid=(char *)NULL;
+ Stmt q; // db query
+ char *zSQL; //build-up sql
+
+ // zSQL = mprintf();
+
+ // [create sql statement]
+ // db_prepare(&q,sqlstmt);
+
+ blob_init(&uuid, zName, -1);
+ if( name_to_uuid(&uuid, 1) ){
+ fossil_panic(g.zErrMsg);
+ }
+
+ /* nParent=db_text(0,"select rid from blob where uuid=%s",uuid.nameofobj); */
+
+ /* int nParent = db_column_int(q, somenum); */
+ return rc;
+}
+
+
+/*
** Undo the current check-out. Unlink all files from the disk.
** Clear the VFILE table.
*/
void uncheckout(int vid){
@@ -157,8 +187,11 @@
noWrite = find_option("dontwrite",0,0)!=0;
if( g.argc!=3 ) usage("?--force? VERSION");
if( !forceFlag && unsaved_changes()==1 ){
fossil_fatal("there are unsaved changes in the current checkout");
+ }
+ if(!checkoutable()){
+ fossil_fatal("the VERSION you requested is not a checkout-able artifact");
}
if( forceFlag ){
db_multi_exec("DELETE FROM vfile");
prior = 0;