Fossil SCM
Added --inverse/-v flag to the tag command, as covered in [https://fossil-scm.org/forum/forumpost/d717561e8b7406fc|forumpost/d717561e8b7406fc].
Commit
890614f13711f96bf6cf1b1a44530e9f5f70f41f7e7fa74a5aa9f40a489c9c6e
Parent
eee161e823e3df1…
1 file changed
+7
-5
+7
-5
| --- src/tag.c | ||
| +++ src/tag.c | ||
| @@ -423,10 +423,11 @@ | ||
| 423 | 423 | ** takes one of: propagated, singleton, cancel. |
| 424 | 424 | ** |
| 425 | 425 | ** Options: |
| 426 | 426 | ** --raw List tags raw names of tags |
| 427 | 427 | ** --tagtype TYPE List only tags of type TYPE |
| 428 | +** -v|--inverse Inverse the meaning of --tagtype TYPE. | |
| 428 | 429 | ** |
| 429 | 430 | ** The option --raw allows the manipulation of all types of tags |
| 430 | 431 | ** used for various internal purposes in fossil. It also shows |
| 431 | 432 | ** "cancel" tags for the "find" and "list" subcommands. You should |
| 432 | 433 | ** not use this option to make changes unless you are sure what |
| @@ -548,12 +549,13 @@ | ||
| 548 | 549 | } |
| 549 | 550 | }else |
| 550 | 551 | |
| 551 | 552 | if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){ |
| 552 | 553 | Stmt q; |
| 553 | - int fRaw = find_option("raw","",0)!=0; | |
| 554 | + const int fRaw = find_option("raw","",0)!=0; | |
| 554 | 555 | const char *zTagType = find_option("tagtype","t",1); |
| 556 | + const int fInverse = find_option("inverse","v",0)!=0; | |
| 555 | 557 | int nTagType = fRaw ? -1 : 0; |
| 556 | 558 | if( zTagType!=0 ){ |
| 557 | 559 | int l = strlen(zTagType); |
| 558 | 560 | if( strncmp(zTagType,"cancel",l)==0 ){ |
| 559 | 561 | nTagType = 0; |
| @@ -568,13 +570,13 @@ | ||
| 568 | 570 | if( g.argc==3 ){ |
| 569 | 571 | db_prepare(&q, |
| 570 | 572 | "SELECT tagname FROM tag" |
| 571 | 573 | " WHERE EXISTS(SELECT 1 FROM tagxref" |
| 572 | 574 | " WHERE tagid=tag.tagid" |
| 573 | - " AND tagtype%c%d)" | |
| 575 | + " AND tagtype%s%d)" | |
| 574 | 576 | " ORDER BY tagname", |
| 575 | - zTagType!=0 ? '=' : '>', | |
| 577 | + zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/, | |
| 576 | 578 | nTagType |
| 577 | 579 | ); |
| 578 | 580 | while( db_step(&q)==SQLITE_ROW ){ |
| 579 | 581 | const char *zName = db_column_text(&q, 0); |
| 580 | 582 | if( fRaw ){ |
| @@ -587,14 +589,14 @@ | ||
| 587 | 589 | }else if( g.argc==4 ){ |
| 588 | 590 | int rid = name_to_rid(g.argv[3]); |
| 589 | 591 | db_prepare(&q, |
| 590 | 592 | "SELECT tagname, value FROM tagxref, tag" |
| 591 | 593 | " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" |
| 592 | - " AND tagtype%c%d" | |
| 594 | + " AND tagtype%s%d" | |
| 593 | 595 | " ORDER BY tagname", |
| 594 | 596 | rid, |
| 595 | - zTagType!=0 ? '=' : '>', | |
| 597 | + zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/, | |
| 596 | 598 | nTagType |
| 597 | 599 | ); |
| 598 | 600 | while( db_step(&q)==SQLITE_ROW ){ |
| 599 | 601 | const char *zName = db_column_text(&q, 0); |
| 600 | 602 | const char *zValue = db_column_text(&q, 1); |
| 601 | 603 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -423,10 +423,11 @@ | |
| 423 | ** takes one of: propagated, singleton, cancel. |
| 424 | ** |
| 425 | ** Options: |
| 426 | ** --raw List tags raw names of tags |
| 427 | ** --tagtype TYPE List only tags of type TYPE |
| 428 | ** |
| 429 | ** The option --raw allows the manipulation of all types of tags |
| 430 | ** used for various internal purposes in fossil. It also shows |
| 431 | ** "cancel" tags for the "find" and "list" subcommands. You should |
| 432 | ** not use this option to make changes unless you are sure what |
| @@ -548,12 +549,13 @@ | |
| 548 | } |
| 549 | }else |
| 550 | |
| 551 | if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){ |
| 552 | Stmt q; |
| 553 | int fRaw = find_option("raw","",0)!=0; |
| 554 | const char *zTagType = find_option("tagtype","t",1); |
| 555 | int nTagType = fRaw ? -1 : 0; |
| 556 | if( zTagType!=0 ){ |
| 557 | int l = strlen(zTagType); |
| 558 | if( strncmp(zTagType,"cancel",l)==0 ){ |
| 559 | nTagType = 0; |
| @@ -568,13 +570,13 @@ | |
| 568 | if( g.argc==3 ){ |
| 569 | db_prepare(&q, |
| 570 | "SELECT tagname FROM tag" |
| 571 | " WHERE EXISTS(SELECT 1 FROM tagxref" |
| 572 | " WHERE tagid=tag.tagid" |
| 573 | " AND tagtype%c%d)" |
| 574 | " ORDER BY tagname", |
| 575 | zTagType!=0 ? '=' : '>', |
| 576 | nTagType |
| 577 | ); |
| 578 | while( db_step(&q)==SQLITE_ROW ){ |
| 579 | const char *zName = db_column_text(&q, 0); |
| 580 | if( fRaw ){ |
| @@ -587,14 +589,14 @@ | |
| 587 | }else if( g.argc==4 ){ |
| 588 | int rid = name_to_rid(g.argv[3]); |
| 589 | db_prepare(&q, |
| 590 | "SELECT tagname, value FROM tagxref, tag" |
| 591 | " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" |
| 592 | " AND tagtype%c%d" |
| 593 | " ORDER BY tagname", |
| 594 | rid, |
| 595 | zTagType!=0 ? '=' : '>', |
| 596 | nTagType |
| 597 | ); |
| 598 | while( db_step(&q)==SQLITE_ROW ){ |
| 599 | const char *zName = db_column_text(&q, 0); |
| 600 | const char *zValue = db_column_text(&q, 1); |
| 601 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -423,10 +423,11 @@ | |
| 423 | ** takes one of: propagated, singleton, cancel. |
| 424 | ** |
| 425 | ** Options: |
| 426 | ** --raw List tags raw names of tags |
| 427 | ** --tagtype TYPE List only tags of type TYPE |
| 428 | ** -v|--inverse Inverse the meaning of --tagtype TYPE. |
| 429 | ** |
| 430 | ** The option --raw allows the manipulation of all types of tags |
| 431 | ** used for various internal purposes in fossil. It also shows |
| 432 | ** "cancel" tags for the "find" and "list" subcommands. You should |
| 433 | ** not use this option to make changes unless you are sure what |
| @@ -548,12 +549,13 @@ | |
| 549 | } |
| 550 | }else |
| 551 | |
| 552 | if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){ |
| 553 | Stmt q; |
| 554 | const int fRaw = find_option("raw","",0)!=0; |
| 555 | const char *zTagType = find_option("tagtype","t",1); |
| 556 | const int fInverse = find_option("inverse","v",0)!=0; |
| 557 | int nTagType = fRaw ? -1 : 0; |
| 558 | if( zTagType!=0 ){ |
| 559 | int l = strlen(zTagType); |
| 560 | if( strncmp(zTagType,"cancel",l)==0 ){ |
| 561 | nTagType = 0; |
| @@ -568,13 +570,13 @@ | |
| 570 | if( g.argc==3 ){ |
| 571 | db_prepare(&q, |
| 572 | "SELECT tagname FROM tag" |
| 573 | " WHERE EXISTS(SELECT 1 FROM tagxref" |
| 574 | " WHERE tagid=tag.tagid" |
| 575 | " AND tagtype%s%d)" |
| 576 | " ORDER BY tagname", |
| 577 | zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/, |
| 578 | nTagType |
| 579 | ); |
| 580 | while( db_step(&q)==SQLITE_ROW ){ |
| 581 | const char *zName = db_column_text(&q, 0); |
| 582 | if( fRaw ){ |
| @@ -587,14 +589,14 @@ | |
| 589 | }else if( g.argc==4 ){ |
| 590 | int rid = name_to_rid(g.argv[3]); |
| 591 | db_prepare(&q, |
| 592 | "SELECT tagname, value FROM tagxref, tag" |
| 593 | " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" |
| 594 | " AND tagtype%s%d" |
| 595 | " ORDER BY tagname", |
| 596 | rid, |
| 597 | zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/, |
| 598 | nTagType |
| 599 | ); |
| 600 | while( db_step(&q)==SQLITE_ROW ){ |
| 601 | const char *zName = db_column_text(&q, 0); |
| 602 | const char *zValue = db_column_text(&q, 1); |
| 603 |