Fossil SCM

For the 'tag' command, parse all options after the sub-commands, so that no unsupported options can be used (for example, disallow 'fossil tag cancel --propagate ...'), and to have a consistent command-line format with sub-commands followed by options

florian 2018-12-26 14:25 UTC cmd-options-amend
Commit 2efcd19f14a0f9526184e4d15d02ea8a49f0f9c9024c1bb8625578fc187beff0
1 file changed +9 -3
+9 -3
--- src/tag.c
+++ src/tag.c
@@ -432,13 +432,10 @@
432432
** will assume that "decaf" is a tag/branch name.
433433
**
434434
*/
435435
void tag_cmd(void){
436436
int n;
437
- int fRaw = find_option("raw","",0)!=0;
438
- int fPropagate = find_option("propagate","",0)!=0;
439
- const char *zPrefix = fRaw ? "" : "sym-";
440437
441438
db_find_and_open_repository(0, 0);
442439
if( g.argc<3 ){
443440
goto tag_cmd_usage;
444441
}
@@ -448,10 +445,13 @@
448445
}
449446
450447
if( strncmp(g.argv[2],"add",n)==0 ){
451448
char *zValue;
452449
int dryRun = 0;
450
+ int fRaw = find_option("raw","",0)!=0;
451
+ const char *zPrefix = fRaw ? "" : "sym-";
452
+ int fPropagate = find_option("propagate","",0)!=0;
453453
const char *zDateOvrd = find_option("date-override",0,1);
454454
const char *zUserOvrd = find_option("user-override",0,1);
455455
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
456456
if( g.argc!=5 && g.argc!=6 ){
457457
usage("add ?options? TAGNAME CHECK-IN ?VALUE?");
@@ -468,10 +468,12 @@
468468
"Use the \"fossil branch new\" command instead.");
469469
}else
470470
471471
if( strncmp(g.argv[2],"cancel",n)==0 ){
472472
int dryRun = 0;
473
+ int fRaw = find_option("raw","",0)!=0;
474
+ const char *zPrefix = fRaw ? "" : "sym-";
473475
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
474476
if( g.argc!=5 ){
475477
usage("cancel ?options? TAGNAME CHECK-IN");
476478
}
477479
db_begin_transaction();
@@ -479,10 +481,12 @@
479481
db_end_transaction(0);
480482
}else
481483
482484
if( strncmp(g.argv[2],"find",n)==0 ){
483485
Stmt q;
486
+ int fRaw = find_option("raw","",0)!=0;
487
+ const char *zPrefix = fRaw ? "" : "sym-";
484488
const char *zFindLimit = find_option("limit","n",1);
485489
const int nFindLimit = zFindLimit ? atoi(zFindLimit) : -2000;
486490
const char *zType = find_option("type","t",1);
487491
Blob sql = empty_blob;
488492
if( zType==0 || zType[0]==0 ) zType = "*";
@@ -528,10 +532,12 @@
528532
}
529533
}else
530534
531535
if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
532536
Stmt q;
537
+ int fRaw = find_option("raw","",0)!=0;
538
+ const char *zPrefix = fRaw ? "" : "sym-";
533539
if( g.argc==3 ){
534540
db_prepare(&q,
535541
"SELECT tagname FROM tag"
536542
" WHERE EXISTS(SELECT 1 FROM tagxref"
537543
" WHERE tagid=tag.tagid"
538544
--- src/tag.c
+++ src/tag.c
@@ -432,13 +432,10 @@
432 ** will assume that "decaf" is a tag/branch name.
433 **
434 */
435 void tag_cmd(void){
436 int n;
437 int fRaw = find_option("raw","",0)!=0;
438 int fPropagate = find_option("propagate","",0)!=0;
439 const char *zPrefix = fRaw ? "" : "sym-";
440
441 db_find_and_open_repository(0, 0);
442 if( g.argc<3 ){
443 goto tag_cmd_usage;
444 }
@@ -448,10 +445,13 @@
448 }
449
450 if( strncmp(g.argv[2],"add",n)==0 ){
451 char *zValue;
452 int dryRun = 0;
 
 
 
453 const char *zDateOvrd = find_option("date-override",0,1);
454 const char *zUserOvrd = find_option("user-override",0,1);
455 if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
456 if( g.argc!=5 && g.argc!=6 ){
457 usage("add ?options? TAGNAME CHECK-IN ?VALUE?");
@@ -468,10 +468,12 @@
468 "Use the \"fossil branch new\" command instead.");
469 }else
470
471 if( strncmp(g.argv[2],"cancel",n)==0 ){
472 int dryRun = 0;
 
 
473 if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
474 if( g.argc!=5 ){
475 usage("cancel ?options? TAGNAME CHECK-IN");
476 }
477 db_begin_transaction();
@@ -479,10 +481,12 @@
479 db_end_transaction(0);
480 }else
481
482 if( strncmp(g.argv[2],"find",n)==0 ){
483 Stmt q;
 
 
484 const char *zFindLimit = find_option("limit","n",1);
485 const int nFindLimit = zFindLimit ? atoi(zFindLimit) : -2000;
486 const char *zType = find_option("type","t",1);
487 Blob sql = empty_blob;
488 if( zType==0 || zType[0]==0 ) zType = "*";
@@ -528,10 +532,12 @@
528 }
529 }else
530
531 if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
532 Stmt q;
 
 
533 if( g.argc==3 ){
534 db_prepare(&q,
535 "SELECT tagname FROM tag"
536 " WHERE EXISTS(SELECT 1 FROM tagxref"
537 " WHERE tagid=tag.tagid"
538
--- src/tag.c
+++ src/tag.c
@@ -432,13 +432,10 @@
432 ** will assume that "decaf" is a tag/branch name.
433 **
434 */
435 void tag_cmd(void){
436 int n;
 
 
 
437
438 db_find_and_open_repository(0, 0);
439 if( g.argc<3 ){
440 goto tag_cmd_usage;
441 }
@@ -448,10 +445,13 @@
445 }
446
447 if( strncmp(g.argv[2],"add",n)==0 ){
448 char *zValue;
449 int dryRun = 0;
450 int fRaw = find_option("raw","",0)!=0;
451 const char *zPrefix = fRaw ? "" : "sym-";
452 int fPropagate = find_option("propagate","",0)!=0;
453 const char *zDateOvrd = find_option("date-override",0,1);
454 const char *zUserOvrd = find_option("user-override",0,1);
455 if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
456 if( g.argc!=5 && g.argc!=6 ){
457 usage("add ?options? TAGNAME CHECK-IN ?VALUE?");
@@ -468,10 +468,12 @@
468 "Use the \"fossil branch new\" command instead.");
469 }else
470
471 if( strncmp(g.argv[2],"cancel",n)==0 ){
472 int dryRun = 0;
473 int fRaw = find_option("raw","",0)!=0;
474 const char *zPrefix = fRaw ? "" : "sym-";
475 if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
476 if( g.argc!=5 ){
477 usage("cancel ?options? TAGNAME CHECK-IN");
478 }
479 db_begin_transaction();
@@ -479,10 +481,12 @@
481 db_end_transaction(0);
482 }else
483
484 if( strncmp(g.argv[2],"find",n)==0 ){
485 Stmt q;
486 int fRaw = find_option("raw","",0)!=0;
487 const char *zPrefix = fRaw ? "" : "sym-";
488 const char *zFindLimit = find_option("limit","n",1);
489 const int nFindLimit = zFindLimit ? atoi(zFindLimit) : -2000;
490 const char *zType = find_option("type","t",1);
491 Blob sql = empty_blob;
492 if( zType==0 || zType[0]==0 ) zType = "*";
@@ -528,10 +532,12 @@
532 }
533 }else
534
535 if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
536 Stmt q;
537 int fRaw = find_option("raw","",0)!=0;
538 const char *zPrefix = fRaw ? "" : "sym-";
539 if( g.argc==3 ){
540 db_prepare(&q,
541 "SELECT tagname FROM tag"
542 " WHERE EXISTS(SELECT 1 FROM tagxref"
543 " WHERE tagid=tag.tagid"
544

Keyboard Shortcuts

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