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.
Commit
9f63c8a3fe1ea68d135793e29697f346ed0299ce
Parent
3753b87d949a77f…
1 file changed
+8
-3
+8
-3
| --- src/bundle.c | ||
| +++ src/bundle.c | ||
| @@ -66,10 +66,12 @@ | ||
| 66 | 66 | static void bundle_ls_cmd(void){ |
| 67 | 67 | Stmt q; |
| 68 | 68 | sqlite3_int64 sumSz = 0; |
| 69 | 69 | sqlite3_int64 sumLen = 0; |
| 70 | 70 | int bDetails = find_option("details","l",0)!=0; |
| 71 | + verify_all_options(); | |
| 72 | + if( g.argc!=4 ) usage("ls BUNDLE ?OPTIONS?"); | |
| 71 | 73 | bundle_attach_file(g.argv[3], "b1", 0); |
| 72 | 74 | db_prepare(&q, |
| 73 | 75 | "SELECT bcname, bcvalue FROM bconfig" |
| 74 | 76 | " WHERE typeof(bcvalue)='text'" |
| 75 | 77 | " AND bcvalue NOT GLOB char(0x2a,0x0a,0x2a);" |
| @@ -182,11 +184,11 @@ | ||
| 182 | 184 | if( zFrom ){ |
| 183 | 185 | rid = name_to_typed_rid(zFrom, "ci"); |
| 184 | 186 | }else if( zBr ){ |
| 185 | 187 | rid = name_to_typed_rid(zBr, "br"); |
| 186 | 188 | }else if( zCkin==0 ){ |
| 187 | - fossil_fatal("need on of: --branch, --from, --checkin"); | |
| 189 | + fossil_fatal("need one of: --branch, --from, --checkin"); | |
| 188 | 190 | } |
| 189 | 191 | db_multi_exec("INSERT OR IGNORE INTO \"%w\" VALUES(%d)", zTab, rid); |
| 190 | 192 | if( rid!=endRid ){ |
| 191 | 193 | Blob sql; |
| 192 | 194 | blob_zero(&sql); |
| @@ -266,10 +268,11 @@ | ||
| 266 | 268 | subtree_from_arguments("tobundle"); |
| 267 | 269 | find_checkin_associates("tobundle", 0); |
| 268 | 270 | verify_all_options(); |
| 269 | 271 | describe_artifacts("IN tobundle"); |
| 270 | 272 | |
| 273 | + if( g.argc!=4 ) usage("export BUNDLE ?OPTIONS?"); | |
| 271 | 274 | /* Create the new bundle */ |
| 272 | 275 | bundle_attach_file(g.argv[3], "b1", 1); |
| 273 | 276 | db_begin_transaction(); |
| 274 | 277 | |
| 275 | 278 | /* Add 'mtime' and 'project-code' entries to the bconfig table */ |
| @@ -508,12 +511,12 @@ | ||
| 508 | 511 | ** Write elements of a bundle on standard output |
| 509 | 512 | */ |
| 510 | 513 | static void bundle_cat_cmd(void){ |
| 511 | 514 | int i; |
| 512 | 515 | Blob x; |
| 513 | - if( g.argc<5 ) usage("cat BUNDLE UUID..."); | |
| 514 | 516 | verify_all_options(); |
| 517 | + if( g.argc<5 ) usage("cat BUNDLE UUID..."); | |
| 515 | 518 | bundle_attach_file(g.argv[3], "b1", 1); |
| 516 | 519 | blob_zero(&x); |
| 517 | 520 | for(i=4; i<g.argc; i++){ |
| 518 | 521 | int blobid = db_int(0,"SELECT blobid FROM bblob WHERE uuid LIKE '%q%%'", |
| 519 | 522 | g.argv[i]); |
| @@ -539,10 +542,11 @@ | ||
| 539 | 542 | static void bundle_import_cmd(void){ |
| 540 | 543 | int forceFlag = find_option("force","f",0)!=0; |
| 541 | 544 | int isPriv = find_option("publish",0,0)==0; |
| 542 | 545 | char *zMissingDeltas; |
| 543 | 546 | verify_all_options(); |
| 547 | + if ( g.argc!=4 ) usage("import BUNDLE ?OPTIONS?"); | |
| 544 | 548 | bundle_attach_file(g.argv[3], "b1", 1); |
| 545 | 549 | |
| 546 | 550 | /* Only import a bundle that was generated from a repo with the same |
| 547 | 551 | ** project code, unless the --force flag is true */ |
| 548 | 552 | if( !forceFlag ){ |
| @@ -606,10 +610,11 @@ | ||
| 606 | 610 | static void bundle_purge_cmd(void){ |
| 607 | 611 | int bForce = find_option("force",0,0)!=0; |
| 608 | 612 | int bTest = find_option("test",0,0)!=0; /* Undocumented --test option */ |
| 609 | 613 | const char *zFile = g.argv[3]; |
| 610 | 614 | verify_all_options(); |
| 615 | + if ( g.argc!=4 ) usage("purge BUNDLE ?OPTIONS?"); | |
| 611 | 616 | bundle_attach_file(zFile, "b1", 0); |
| 612 | 617 | db_begin_transaction(); |
| 613 | 618 | |
| 614 | 619 | /* Find all checkins of the bundle */ |
| 615 | 620 | db_multi_exec( |
| @@ -753,11 +758,11 @@ | ||
| 753 | 758 | ** fossil bundle purge BUNDLE Undo an import |
| 754 | 759 | */ |
| 755 | 760 | void bundle_cmd(void){ |
| 756 | 761 | const char *zSubcmd; |
| 757 | 762 | int n; |
| 758 | - if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?ARGUMENTS?"); | |
| 763 | + if( g.argc<4 ) usage("SUBCOMMAND BUNDLE ?OPTIONS?"); | |
| 759 | 764 | zSubcmd = g.argv[2]; |
| 760 | 765 | db_find_and_open_repository(0,0); |
| 761 | 766 | n = (int)strlen(zSubcmd); |
| 762 | 767 | if( strncmp(zSubcmd, "append", n)==0 ){ |
| 763 | 768 | bundle_append_cmd(); |
| 764 | 769 |
| --- 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 |