Fossil SCM

Added --inverse/-v flag to the tag command, as covered in [https://fossil-scm.org/forum/forumpost/d717561e8b7406fc|forumpost/d717561e8b7406fc].

stephan 2020-01-27 06:56 trunk merge
Commit 890614f13711f96bf6cf1b1a44530e9f5f70f41f7e7fa74a5aa9f40a489c9c6e
1 file changed +7 -5
+7 -5
--- src/tag.c
+++ src/tag.c
@@ -423,10 +423,11 @@
423423
** takes one of: propagated, singleton, cancel.
424424
**
425425
** Options:
426426
** --raw List tags raw names of tags
427427
** --tagtype TYPE List only tags of type TYPE
428
+** -v|--inverse Inverse the meaning of --tagtype TYPE.
428429
**
429430
** The option --raw allows the manipulation of all types of tags
430431
** used for various internal purposes in fossil. It also shows
431432
** "cancel" tags for the "find" and "list" subcommands. You should
432433
** not use this option to make changes unless you are sure what
@@ -548,12 +549,13 @@
548549
}
549550
}else
550551
551552
if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
552553
Stmt q;
553
- int fRaw = find_option("raw","",0)!=0;
554
+ const int fRaw = find_option("raw","",0)!=0;
554555
const char *zTagType = find_option("tagtype","t",1);
556
+ const int fInverse = find_option("inverse","v",0)!=0;
555557
int nTagType = fRaw ? -1 : 0;
556558
if( zTagType!=0 ){
557559
int l = strlen(zTagType);
558560
if( strncmp(zTagType,"cancel",l)==0 ){
559561
nTagType = 0;
@@ -568,13 +570,13 @@
568570
if( g.argc==3 ){
569571
db_prepare(&q,
570572
"SELECT tagname FROM tag"
571573
" WHERE EXISTS(SELECT 1 FROM tagxref"
572574
" WHERE tagid=tag.tagid"
573
- " AND tagtype%c%d)"
575
+ " AND tagtype%s%d)"
574576
" ORDER BY tagname",
575
- zTagType!=0 ? '=' : '>',
577
+ zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
576578
nTagType
577579
);
578580
while( db_step(&q)==SQLITE_ROW ){
579581
const char *zName = db_column_text(&q, 0);
580582
if( fRaw ){
@@ -587,14 +589,14 @@
587589
}else if( g.argc==4 ){
588590
int rid = name_to_rid(g.argv[3]);
589591
db_prepare(&q,
590592
"SELECT tagname, value FROM tagxref, tag"
591593
" WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
592
- " AND tagtype%c%d"
594
+ " AND tagtype%s%d"
593595
" ORDER BY tagname",
594596
rid,
595
- zTagType!=0 ? '=' : '>',
597
+ zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
596598
nTagType
597599
);
598600
while( db_step(&q)==SQLITE_ROW ){
599601
const char *zName = db_column_text(&q, 0);
600602
const char *zValue = db_column_text(&q, 1);
601603
--- 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

Keyboard Shortcuts

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