Fossil SCM

Try to avoid creating files with names of unrecognized --options by checking for explicit argument count where a file is required. Correct minor typo in error output.

andybradford 2014-12-02 05:50 UTC DBP-workflow
Commit 9f63c8a3fe1ea68d135793e29697f346ed0299ce
1 file changed +8 -3
+8 -3
--- src/bundle.c
+++ src/bundle.c
@@ -66,10 +66,12 @@
6666
static void bundle_ls_cmd(void){
6767
Stmt q;
6868
sqlite3_int64 sumSz = 0;
6969
sqlite3_int64 sumLen = 0;
7070
int bDetails = find_option("details","l",0)!=0;
71
+ verify_all_options();
72
+ if( g.argc!=4 ) usage("ls BUNDLE ?OPTIONS?");
7173
bundle_attach_file(g.argv[3], "b1", 0);
7274
db_prepare(&q,
7375
"SELECT bcname, bcvalue FROM bconfig"
7476
" WHERE typeof(bcvalue)='text'"
7577
" AND bcvalue NOT GLOB char(0x2a,0x0a,0x2a);"
@@ -182,11 +184,11 @@
182184
if( zFrom ){
183185
rid = name_to_typed_rid(zFrom, "ci");
184186
}else if( zBr ){
185187
rid = name_to_typed_rid(zBr, "br");
186188
}else if( zCkin==0 ){
187
- fossil_fatal("need on of: --branch, --from, --checkin");
189
+ fossil_fatal("need one of: --branch, --from, --checkin");
188190
}
189191
db_multi_exec("INSERT OR IGNORE INTO \"%w\" VALUES(%d)", zTab, rid);
190192
if( rid!=endRid ){
191193
Blob sql;
192194
blob_zero(&sql);
@@ -266,10 +268,11 @@
266268
subtree_from_arguments("tobundle");
267269
find_checkin_associates("tobundle", 0);
268270
verify_all_options();
269271
describe_artifacts("IN tobundle");
270272
273
+ if( g.argc!=4 ) usage("export BUNDLE ?OPTIONS?");
271274
/* Create the new bundle */
272275
bundle_attach_file(g.argv[3], "b1", 1);
273276
db_begin_transaction();
274277
275278
/* Add 'mtime' and 'project-code' entries to the bconfig table */
@@ -508,12 +511,12 @@
508511
** Write elements of a bundle on standard output
509512
*/
510513
static void bundle_cat_cmd(void){
511514
int i;
512515
Blob x;
513
- if( g.argc<5 ) usage("cat BUNDLE UUID...");
514516
verify_all_options();
517
+ if( g.argc<5 ) usage("cat BUNDLE UUID...");
515518
bundle_attach_file(g.argv[3], "b1", 1);
516519
blob_zero(&x);
517520
for(i=4; i<g.argc; i++){
518521
int blobid = db_int(0,"SELECT blobid FROM bblob WHERE uuid LIKE '%q%%'",
519522
g.argv[i]);
@@ -539,10 +542,11 @@
539542
static void bundle_import_cmd(void){
540543
int forceFlag = find_option("force","f",0)!=0;
541544
int isPriv = find_option("publish",0,0)==0;
542545
char *zMissingDeltas;
543546
verify_all_options();
547
+ if ( g.argc!=4 ) usage("import BUNDLE ?OPTIONS?");
544548
bundle_attach_file(g.argv[3], "b1", 1);
545549
546550
/* Only import a bundle that was generated from a repo with the same
547551
** project code, unless the --force flag is true */
548552
if( !forceFlag ){
@@ -606,10 +610,11 @@
606610
static void bundle_purge_cmd(void){
607611
int bForce = find_option("force",0,0)!=0;
608612
int bTest = find_option("test",0,0)!=0; /* Undocumented --test option */
609613
const char *zFile = g.argv[3];
610614
verify_all_options();
615
+ if ( g.argc!=4 ) usage("purge BUNDLE ?OPTIONS?");
611616
bundle_attach_file(zFile, "b1", 0);
612617
db_begin_transaction();
613618
614619
/* Find all checkins of the bundle */
615620
db_multi_exec(
@@ -753,11 +758,11 @@
753758
** fossil bundle purge BUNDLE Undo an import
754759
*/
755760
void bundle_cmd(void){
756761
const char *zSubcmd;
757762
int n;
758
- if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?ARGUMENTS?");
763
+ if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?OPTIONS?");
759764
zSubcmd = g.argv[2];
760765
db_find_and_open_repository(0,0);
761766
n = (int)strlen(zSubcmd);
762767
if( strncmp(zSubcmd, "append", n)==0 ){
763768
bundle_append_cmd();
764769
--- src/bundle.c
+++ src/bundle.c
@@ -66,10 +66,12 @@
66 static void bundle_ls_cmd(void){
67 Stmt q;
68 sqlite3_int64 sumSz = 0;
69 sqlite3_int64 sumLen = 0;
70 int bDetails = find_option("details","l",0)!=0;
 
 
71 bundle_attach_file(g.argv[3], "b1", 0);
72 db_prepare(&q,
73 "SELECT bcname, bcvalue FROM bconfig"
74 " WHERE typeof(bcvalue)='text'"
75 " AND bcvalue NOT GLOB char(0x2a,0x0a,0x2a);"
@@ -182,11 +184,11 @@
182 if( zFrom ){
183 rid = name_to_typed_rid(zFrom, "ci");
184 }else if( zBr ){
185 rid = name_to_typed_rid(zBr, "br");
186 }else if( zCkin==0 ){
187 fossil_fatal("need on of: --branch, --from, --checkin");
188 }
189 db_multi_exec("INSERT OR IGNORE INTO \"%w\" VALUES(%d)", zTab, rid);
190 if( rid!=endRid ){
191 Blob sql;
192 blob_zero(&sql);
@@ -266,10 +268,11 @@
266 subtree_from_arguments("tobundle");
267 find_checkin_associates("tobundle", 0);
268 verify_all_options();
269 describe_artifacts("IN tobundle");
270
 
271 /* Create the new bundle */
272 bundle_attach_file(g.argv[3], "b1", 1);
273 db_begin_transaction();
274
275 /* Add 'mtime' and 'project-code' entries to the bconfig table */
@@ -508,12 +511,12 @@
508 ** Write elements of a bundle on standard output
509 */
510 static void bundle_cat_cmd(void){
511 int i;
512 Blob x;
513 if( g.argc<5 ) usage("cat BUNDLE UUID...");
514 verify_all_options();
 
515 bundle_attach_file(g.argv[3], "b1", 1);
516 blob_zero(&x);
517 for(i=4; i<g.argc; i++){
518 int blobid = db_int(0,"SELECT blobid FROM bblob WHERE uuid LIKE '%q%%'",
519 g.argv[i]);
@@ -539,10 +542,11 @@
539 static void bundle_import_cmd(void){
540 int forceFlag = find_option("force","f",0)!=0;
541 int isPriv = find_option("publish",0,0)==0;
542 char *zMissingDeltas;
543 verify_all_options();
 
544 bundle_attach_file(g.argv[3], "b1", 1);
545
546 /* Only import a bundle that was generated from a repo with the same
547 ** project code, unless the --force flag is true */
548 if( !forceFlag ){
@@ -606,10 +610,11 @@
606 static void bundle_purge_cmd(void){
607 int bForce = find_option("force",0,0)!=0;
608 int bTest = find_option("test",0,0)!=0; /* Undocumented --test option */
609 const char *zFile = g.argv[3];
610 verify_all_options();
 
611 bundle_attach_file(zFile, "b1", 0);
612 db_begin_transaction();
613
614 /* Find all checkins of the bundle */
615 db_multi_exec(
@@ -753,11 +758,11 @@
753 ** fossil bundle purge BUNDLE Undo an import
754 */
755 void bundle_cmd(void){
756 const char *zSubcmd;
757 int n;
758 if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?ARGUMENTS?");
759 zSubcmd = g.argv[2];
760 db_find_and_open_repository(0,0);
761 n = (int)strlen(zSubcmd);
762 if( strncmp(zSubcmd, "append", n)==0 ){
763 bundle_append_cmd();
764
--- src/bundle.c
+++ src/bundle.c
@@ -66,10 +66,12 @@
66 static void bundle_ls_cmd(void){
67 Stmt q;
68 sqlite3_int64 sumSz = 0;
69 sqlite3_int64 sumLen = 0;
70 int bDetails = find_option("details","l",0)!=0;
71 verify_all_options();
72 if( g.argc!=4 ) usage("ls BUNDLE ?OPTIONS?");
73 bundle_attach_file(g.argv[3], "b1", 0);
74 db_prepare(&q,
75 "SELECT bcname, bcvalue FROM bconfig"
76 " WHERE typeof(bcvalue)='text'"
77 " AND bcvalue NOT GLOB char(0x2a,0x0a,0x2a);"
@@ -182,11 +184,11 @@
184 if( zFrom ){
185 rid = name_to_typed_rid(zFrom, "ci");
186 }else if( zBr ){
187 rid = name_to_typed_rid(zBr, "br");
188 }else if( zCkin==0 ){
189 fossil_fatal("need one of: --branch, --from, --checkin");
190 }
191 db_multi_exec("INSERT OR IGNORE INTO \"%w\" VALUES(%d)", zTab, rid);
192 if( rid!=endRid ){
193 Blob sql;
194 blob_zero(&sql);
@@ -266,10 +268,11 @@
268 subtree_from_arguments("tobundle");
269 find_checkin_associates("tobundle", 0);
270 verify_all_options();
271 describe_artifacts("IN tobundle");
272
273 if( g.argc!=4 ) usage("export BUNDLE ?OPTIONS?");
274 /* Create the new bundle */
275 bundle_attach_file(g.argv[3], "b1", 1);
276 db_begin_transaction();
277
278 /* Add 'mtime' and 'project-code' entries to the bconfig table */
@@ -508,12 +511,12 @@
511 ** Write elements of a bundle on standard output
512 */
513 static void bundle_cat_cmd(void){
514 int i;
515 Blob x;
 
516 verify_all_options();
517 if( g.argc<5 ) usage("cat BUNDLE UUID...");
518 bundle_attach_file(g.argv[3], "b1", 1);
519 blob_zero(&x);
520 for(i=4; i<g.argc; i++){
521 int blobid = db_int(0,"SELECT blobid FROM bblob WHERE uuid LIKE '%q%%'",
522 g.argv[i]);
@@ -539,10 +542,11 @@
542 static void bundle_import_cmd(void){
543 int forceFlag = find_option("force","f",0)!=0;
544 int isPriv = find_option("publish",0,0)==0;
545 char *zMissingDeltas;
546 verify_all_options();
547 if ( g.argc!=4 ) usage("import BUNDLE ?OPTIONS?");
548 bundle_attach_file(g.argv[3], "b1", 1);
549
550 /* Only import a bundle that was generated from a repo with the same
551 ** project code, unless the --force flag is true */
552 if( !forceFlag ){
@@ -606,10 +610,11 @@
610 static void bundle_purge_cmd(void){
611 int bForce = find_option("force",0,0)!=0;
612 int bTest = find_option("test",0,0)!=0; /* Undocumented --test option */
613 const char *zFile = g.argv[3];
614 verify_all_options();
615 if ( g.argc!=4 ) usage("purge BUNDLE ?OPTIONS?");
616 bundle_attach_file(zFile, "b1", 0);
617 db_begin_transaction();
618
619 /* Find all checkins of the bundle */
620 db_multi_exec(
@@ -753,11 +758,11 @@
758 ** fossil bundle purge BUNDLE Undo an import
759 */
760 void bundle_cmd(void){
761 const char *zSubcmd;
762 int n;
763 if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?OPTIONS?");
764 zSubcmd = g.argv[2];
765 db_find_and_open_repository(0,0);
766 n = (int)strlen(zSubcmd);
767 if( strncmp(zSubcmd, "append", n)==0 ){
768 bundle_append_cmd();
769

Keyboard Shortcuts

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