Fossil SCM

Add the ability for 'branch list' to filter the branches that have/have not been merged into the current branch.

danield 2023-09-14 08:25 trunk merge
Commit 8ff63db2e66013a5b6dc8108bb874dea48c48f8892b5f4762e7771b29ee662aa
+22 -4
--- src/branch.c
+++ src/branch.c
@@ -276,10 +276,12 @@
276276
#define BRL_BOTH 0x003 /* Show both open and closed branches */
277277
#define BRL_OPEN_CLOSED_MASK 0x003
278278
#define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279279
#define BRL_REVERSE 0x008 /* Reverse the sort order */
280280
#define BRL_PRIVATE 0x010 /* Show only private branches */
281
+#define BRL_MERGED 0x020 /* Show only merged branches */
282
+#define BRL_UNMERGED 0x040 /* Show only unmerged branches */
281283
282284
#endif /* INTERFACE */
283285
284286
/*
285287
** Prepare a query that will list branches.
@@ -305,32 +307,33 @@
305307
/* Ignore nLimitMRU if no chronological sort requested. */
306308
if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
307309
/* Undocumented: invert negative values for nLimitMRU, so that command-line
308310
** arguments similar to `head -5' with "option numbers" are possible. */
309311
if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
310
- blob_append_sql(&sql,"SELECT name, isprivate FROM ("); /* OUTER QUERY */
312
+ blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
311313
switch( brFlags & BRL_OPEN_CLOSED_MASK ){
312314
case BRL_CLOSED_ONLY: {
313315
blob_append_sql(&sql,
314
- "SELECT name, isprivate, mtime FROM tmp_brlist WHERE isclosed"
316
+ "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
315317
);
316318
break;
317319
}
318320
case BRL_BOTH: {
319321
blob_append_sql(&sql,
320
- "SELECT name, isprivate, mtime FROM tmp_brlist WHERE 1"
322
+ "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE 1"
321323
);
322324
break;
323325
}
324326
case BRL_OPEN_ONLY: {
325327
blob_append_sql(&sql,
326
- "SELECT name, isprivate, mtime FROM tmp_brlist WHERE NOT isclosed"
328
+ "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE NOT isclosed"
327329
);
328330
break;
329331
}
330332
}
331333
if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
334
+ if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL");
332335
if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
333336
if( brFlags & BRL_ORDERBY_MTIME ){
334337
blob_append_sql(&sql, " ORDER BY -mtime");
335338
}else{
336339
blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
@@ -613,10 +616,12 @@
613616
** List all branches.
614617
**
615618
** Options:
616619
** -a|--all List all branches. Default show only open branches
617620
** -c|--closed List closed branches
621
+** -m|--merged List branches merged into the current branch
622
+** -M|--unmerged List branches not merged into the current branch
618623
** -p List only private branches
619624
** -r Reverse the sort order
620625
** -t Show recently changed branches first
621626
**
622627
** The current branch is marked with an asterisk. Private branches are
@@ -694,11 +699,16 @@
694699
if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
695700
if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
696701
if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
697702
if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
698703
if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
704
+ if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
705
+ if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;
699706
707
+ if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
708
+ fossil_fatal("flags --merged and --unmerged are mutually exclusive");
709
+ }
700710
if( strcmp(zCmd, "lsh")==0 ){
701711
nLimit = 5;
702712
if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
703713
fossil_fatal("the lsh subcommand allows one optional numeric argument");
704714
}
@@ -714,11 +724,19 @@
714724
}
715725
branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
716726
while( db_step(&q)==SQLITE_ROW ){
717727
const char *zBr = db_column_text(&q, 0);
718728
int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;
729
+ const char *zMergeTo = db_column_text(&q, 2);
719730
int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
731
+ if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
732
+ continue;
733
+ }
734
+ if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
735
+ || isCur) ){
736
+ continue;
737
+ }
720738
fossil_print("%s%s%s\n",
721739
( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
722740
(isCur ? "* " : " "), zBr);
723741
}
724742
db_finalize(&q);
725743
--- src/branch.c
+++ src/branch.c
@@ -276,10 +276,12 @@
276 #define BRL_BOTH 0x003 /* Show both open and closed branches */
277 #define BRL_OPEN_CLOSED_MASK 0x003
278 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279 #define BRL_REVERSE 0x008 /* Reverse the sort order */
280 #define BRL_PRIVATE 0x010 /* Show only private branches */
 
 
281
282 #endif /* INTERFACE */
283
284 /*
285 ** Prepare a query that will list branches.
@@ -305,32 +307,33 @@
305 /* Ignore nLimitMRU if no chronological sort requested. */
306 if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
307 /* Undocumented: invert negative values for nLimitMRU, so that command-line
308 ** arguments similar to `head -5' with "option numbers" are possible. */
309 if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
310 blob_append_sql(&sql,"SELECT name, isprivate FROM ("); /* OUTER QUERY */
311 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
312 case BRL_CLOSED_ONLY: {
313 blob_append_sql(&sql,
314 "SELECT name, isprivate, mtime FROM tmp_brlist WHERE isclosed"
315 );
316 break;
317 }
318 case BRL_BOTH: {
319 blob_append_sql(&sql,
320 "SELECT name, isprivate, mtime FROM tmp_brlist WHERE 1"
321 );
322 break;
323 }
324 case BRL_OPEN_ONLY: {
325 blob_append_sql(&sql,
326 "SELECT name, isprivate, mtime FROM tmp_brlist WHERE NOT isclosed"
327 );
328 break;
329 }
330 }
331 if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
 
332 if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
333 if( brFlags & BRL_ORDERBY_MTIME ){
334 blob_append_sql(&sql, " ORDER BY -mtime");
335 }else{
336 blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
@@ -613,10 +616,12 @@
613 ** List all branches.
614 **
615 ** Options:
616 ** -a|--all List all branches. Default show only open branches
617 ** -c|--closed List closed branches
 
 
618 ** -p List only private branches
619 ** -r Reverse the sort order
620 ** -t Show recently changed branches first
621 **
622 ** The current branch is marked with an asterisk. Private branches are
@@ -694,11 +699,16 @@
694 if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
695 if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
696 if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
697 if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
698 if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
 
 
699
 
 
 
700 if( strcmp(zCmd, "lsh")==0 ){
701 nLimit = 5;
702 if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
703 fossil_fatal("the lsh subcommand allows one optional numeric argument");
704 }
@@ -714,11 +724,19 @@
714 }
715 branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
716 while( db_step(&q)==SQLITE_ROW ){
717 const char *zBr = db_column_text(&q, 0);
718 int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;
 
719 int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
 
 
 
 
 
 
 
720 fossil_print("%s%s%s\n",
721 ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
722 (isCur ? "* " : " "), zBr);
723 }
724 db_finalize(&q);
725
--- src/branch.c
+++ src/branch.c
@@ -276,10 +276,12 @@
276 #define BRL_BOTH 0x003 /* Show both open and closed branches */
277 #define BRL_OPEN_CLOSED_MASK 0x003
278 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279 #define BRL_REVERSE 0x008 /* Reverse the sort order */
280 #define BRL_PRIVATE 0x010 /* Show only private branches */
281 #define BRL_MERGED 0x020 /* Show only merged branches */
282 #define BRL_UNMERGED 0x040 /* Show only unmerged branches */
283
284 #endif /* INTERFACE */
285
286 /*
287 ** Prepare a query that will list branches.
@@ -305,32 +307,33 @@
307 /* Ignore nLimitMRU if no chronological sort requested. */
308 if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
309 /* Undocumented: invert negative values for nLimitMRU, so that command-line
310 ** arguments similar to `head -5' with "option numbers" are possible. */
311 if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
312 blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
313 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
314 case BRL_CLOSED_ONLY: {
315 blob_append_sql(&sql,
316 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
317 );
318 break;
319 }
320 case BRL_BOTH: {
321 blob_append_sql(&sql,
322 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE 1"
323 );
324 break;
325 }
326 case BRL_OPEN_ONLY: {
327 blob_append_sql(&sql,
328 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE NOT isclosed"
329 );
330 break;
331 }
332 }
333 if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
334 if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL");
335 if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
336 if( brFlags & BRL_ORDERBY_MTIME ){
337 blob_append_sql(&sql, " ORDER BY -mtime");
338 }else{
339 blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
@@ -613,10 +616,12 @@
616 ** List all branches.
617 **
618 ** Options:
619 ** -a|--all List all branches. Default show only open branches
620 ** -c|--closed List closed branches
621 ** -m|--merged List branches merged into the current branch
622 ** -M|--unmerged List branches not merged into the current branch
623 ** -p List only private branches
624 ** -r Reverse the sort order
625 ** -t Show recently changed branches first
626 **
627 ** The current branch is marked with an asterisk. Private branches are
@@ -694,11 +699,16 @@
699 if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
700 if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
701 if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
702 if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
703 if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
704 if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
705 if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;
706
707 if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
708 fossil_fatal("flags --merged and --unmerged are mutually exclusive");
709 }
710 if( strcmp(zCmd, "lsh")==0 ){
711 nLimit = 5;
712 if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
713 fossil_fatal("the lsh subcommand allows one optional numeric argument");
714 }
@@ -714,11 +724,19 @@
724 }
725 branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
726 while( db_step(&q)==SQLITE_ROW ){
727 const char *zBr = db_column_text(&q, 0);
728 int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;
729 const char *zMergeTo = db_column_text(&q, 2);
730 int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
731 if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
732 continue;
733 }
734 if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
735 || isCur) ){
736 continue;
737 }
738 fossil_print("%s%s%s\n",
739 ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
740 (isCur ? "* " : " "), zBr);
741 }
742 db_finalize(&q);
743
+22 -4
--- src/branch.c
+++ src/branch.c
@@ -276,10 +276,12 @@
276276
#define BRL_BOTH 0x003 /* Show both open and closed branches */
277277
#define BRL_OPEN_CLOSED_MASK 0x003
278278
#define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279279
#define BRL_REVERSE 0x008 /* Reverse the sort order */
280280
#define BRL_PRIVATE 0x010 /* Show only private branches */
281
+#define BRL_MERGED 0x020 /* Show only merged branches */
282
+#define BRL_UNMERGED 0x040 /* Show only unmerged branches */
281283
282284
#endif /* INTERFACE */
283285
284286
/*
285287
** Prepare a query that will list branches.
@@ -305,32 +307,33 @@
305307
/* Ignore nLimitMRU if no chronological sort requested. */
306308
if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
307309
/* Undocumented: invert negative values for nLimitMRU, so that command-line
308310
** arguments similar to `head -5' with "option numbers" are possible. */
309311
if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
310
- blob_append_sql(&sql,"SELECT name, isprivate FROM ("); /* OUTER QUERY */
312
+ blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
311313
switch( brFlags & BRL_OPEN_CLOSED_MASK ){
312314
case BRL_CLOSED_ONLY: {
313315
blob_append_sql(&sql,
314
- "SELECT name, isprivate, mtime FROM tmp_brlist WHERE isclosed"
316
+ "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
315317
);
316318
break;
317319
}
318320
case BRL_BOTH: {
319321
blob_append_sql(&sql,
320
- "SELECT name, isprivate, mtime FROM tmp_brlist WHERE 1"
322
+ "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE 1"
321323
);
322324
break;
323325
}
324326
case BRL_OPEN_ONLY: {
325327
blob_append_sql(&sql,
326
- "SELECT name, isprivate, mtime FROM tmp_brlist WHERE NOT isclosed"
328
+ "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE NOT isclosed"
327329
);
328330
break;
329331
}
330332
}
331333
if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
334
+ if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL");
332335
if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
333336
if( brFlags & BRL_ORDERBY_MTIME ){
334337
blob_append_sql(&sql, " ORDER BY -mtime");
335338
}else{
336339
blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
@@ -613,10 +616,12 @@
613616
** List all branches.
614617
**
615618
** Options:
616619
** -a|--all List all branches. Default show only open branches
617620
** -c|--closed List closed branches
621
+** -m|--merged List branches merged into the current branch
622
+** -M|--unmerged List branches not merged into the current branch
618623
** -p List only private branches
619624
** -r Reverse the sort order
620625
** -t Show recently changed branches first
621626
**
622627
** The current branch is marked with an asterisk. Private branches are
@@ -694,11 +699,16 @@
694699
if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
695700
if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
696701
if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
697702
if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
698703
if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
704
+ if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
705
+ if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;
699706
707
+ if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
708
+ fossil_fatal("flags --merged and --unmerged are mutually exclusive");
709
+ }
700710
if( strcmp(zCmd, "lsh")==0 ){
701711
nLimit = 5;
702712
if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
703713
fossil_fatal("the lsh subcommand allows one optional numeric argument");
704714
}
@@ -714,11 +724,19 @@
714724
}
715725
branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
716726
while( db_step(&q)==SQLITE_ROW ){
717727
const char *zBr = db_column_text(&q, 0);
718728
int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;
729
+ const char *zMergeTo = db_column_text(&q, 2);
719730
int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
731
+ if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
732
+ continue;
733
+ }
734
+ if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
735
+ || isCur) ){
736
+ continue;
737
+ }
720738
fossil_print("%s%s%s\n",
721739
( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
722740
(isCur ? "* " : " "), zBr);
723741
}
724742
db_finalize(&q);
725743
--- src/branch.c
+++ src/branch.c
@@ -276,10 +276,12 @@
276 #define BRL_BOTH 0x003 /* Show both open and closed branches */
277 #define BRL_OPEN_CLOSED_MASK 0x003
278 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279 #define BRL_REVERSE 0x008 /* Reverse the sort order */
280 #define BRL_PRIVATE 0x010 /* Show only private branches */
 
 
281
282 #endif /* INTERFACE */
283
284 /*
285 ** Prepare a query that will list branches.
@@ -305,32 +307,33 @@
305 /* Ignore nLimitMRU if no chronological sort requested. */
306 if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
307 /* Undocumented: invert negative values for nLimitMRU, so that command-line
308 ** arguments similar to `head -5' with "option numbers" are possible. */
309 if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
310 blob_append_sql(&sql,"SELECT name, isprivate FROM ("); /* OUTER QUERY */
311 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
312 case BRL_CLOSED_ONLY: {
313 blob_append_sql(&sql,
314 "SELECT name, isprivate, mtime FROM tmp_brlist WHERE isclosed"
315 );
316 break;
317 }
318 case BRL_BOTH: {
319 blob_append_sql(&sql,
320 "SELECT name, isprivate, mtime FROM tmp_brlist WHERE 1"
321 );
322 break;
323 }
324 case BRL_OPEN_ONLY: {
325 blob_append_sql(&sql,
326 "SELECT name, isprivate, mtime FROM tmp_brlist WHERE NOT isclosed"
327 );
328 break;
329 }
330 }
331 if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
 
332 if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
333 if( brFlags & BRL_ORDERBY_MTIME ){
334 blob_append_sql(&sql, " ORDER BY -mtime");
335 }else{
336 blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
@@ -613,10 +616,12 @@
613 ** List all branches.
614 **
615 ** Options:
616 ** -a|--all List all branches. Default show only open branches
617 ** -c|--closed List closed branches
 
 
618 ** -p List only private branches
619 ** -r Reverse the sort order
620 ** -t Show recently changed branches first
621 **
622 ** The current branch is marked with an asterisk. Private branches are
@@ -694,11 +699,16 @@
694 if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
695 if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
696 if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
697 if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
698 if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
 
 
699
 
 
 
700 if( strcmp(zCmd, "lsh")==0 ){
701 nLimit = 5;
702 if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
703 fossil_fatal("the lsh subcommand allows one optional numeric argument");
704 }
@@ -714,11 +724,19 @@
714 }
715 branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
716 while( db_step(&q)==SQLITE_ROW ){
717 const char *zBr = db_column_text(&q, 0);
718 int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;
 
719 int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
 
 
 
 
 
 
 
720 fossil_print("%s%s%s\n",
721 ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
722 (isCur ? "* " : " "), zBr);
723 }
724 db_finalize(&q);
725
--- src/branch.c
+++ src/branch.c
@@ -276,10 +276,12 @@
276 #define BRL_BOTH 0x003 /* Show both open and closed branches */
277 #define BRL_OPEN_CLOSED_MASK 0x003
278 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
279 #define BRL_REVERSE 0x008 /* Reverse the sort order */
280 #define BRL_PRIVATE 0x010 /* Show only private branches */
281 #define BRL_MERGED 0x020 /* Show only merged branches */
282 #define BRL_UNMERGED 0x040 /* Show only unmerged branches */
283
284 #endif /* INTERFACE */
285
286 /*
287 ** Prepare a query that will list branches.
@@ -305,32 +307,33 @@
307 /* Ignore nLimitMRU if no chronological sort requested. */
308 if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
309 /* Undocumented: invert negative values for nLimitMRU, so that command-line
310 ** arguments similar to `head -5' with "option numbers" are possible. */
311 if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
312 blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
313 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
314 case BRL_CLOSED_ONLY: {
315 blob_append_sql(&sql,
316 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
317 );
318 break;
319 }
320 case BRL_BOTH: {
321 blob_append_sql(&sql,
322 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE 1"
323 );
324 break;
325 }
326 case BRL_OPEN_ONLY: {
327 blob_append_sql(&sql,
328 "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE NOT isclosed"
329 );
330 break;
331 }
332 }
333 if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
334 if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL");
335 if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
336 if( brFlags & BRL_ORDERBY_MTIME ){
337 blob_append_sql(&sql, " ORDER BY -mtime");
338 }else{
339 blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
@@ -613,10 +616,12 @@
616 ** List all branches.
617 **
618 ** Options:
619 ** -a|--all List all branches. Default show only open branches
620 ** -c|--closed List closed branches
621 ** -m|--merged List branches merged into the current branch
622 ** -M|--unmerged List branches not merged into the current branch
623 ** -p List only private branches
624 ** -r Reverse the sort order
625 ** -t Show recently changed branches first
626 **
627 ** The current branch is marked with an asterisk. Private branches are
@@ -694,11 +699,16 @@
699 if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
700 if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
701 if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
702 if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
703 if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
704 if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
705 if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;
706
707 if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
708 fossil_fatal("flags --merged and --unmerged are mutually exclusive");
709 }
710 if( strcmp(zCmd, "lsh")==0 ){
711 nLimit = 5;
712 if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
713 fossil_fatal("the lsh subcommand allows one optional numeric argument");
714 }
@@ -714,11 +724,19 @@
724 }
725 branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
726 while( db_step(&q)==SQLITE_ROW ){
727 const char *zBr = db_column_text(&q, 0);
728 int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;
729 const char *zMergeTo = db_column_text(&q, 2);
730 int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
731 if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
732 continue;
733 }
734 if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0
735 || isCur) ){
736 continue;
737 }
738 fossil_print("%s%s%s\n",
739 ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
740 (isCur ? "* " : " "), zBr);
741 }
742 db_finalize(&q);
743
--- www/changes.wiki
+++ www/changes.wiki
@@ -17,10 +17,12 @@
1717
* Improve defense against denial-of-service with repeated requests that
1818
contain SQL injection attempts.
1919
* Enhance file listings by displaying file sizes and allowing to sort by them.
2020
* The [/help?cmd=fts-config|fossil fts-config] command now shows how much
2121
repository space is used by the full-text index.
22
+ * The [/help?cmd=branch|fossil branch list] command can now filter branches
23
+ that have/have not been merged into the current branch.
2224
2325
2426
<h2 id='v2_22'>Changes for version 2.22 (2023-05-31)</h2>
2527
* Enhancements to the [/help?cmd=/timeline|/timeline webpage]: <ol type="a">
2628
<li> Add the ft=TAG query parameter which in combination with d=Y
2729
--- www/changes.wiki
+++ www/changes.wiki
@@ -17,10 +17,12 @@
17 * Improve defense against denial-of-service with repeated requests that
18 contain SQL injection attempts.
19 * Enhance file listings by displaying file sizes and allowing to sort by them.
20 * The [/help?cmd=fts-config|fossil fts-config] command now shows how much
21 repository space is used by the full-text index.
 
 
22
23
24 <h2 id='v2_22'>Changes for version 2.22 (2023-05-31)</h2>
25 * Enhancements to the [/help?cmd=/timeline|/timeline webpage]: <ol type="a">
26 <li> Add the ft=TAG query parameter which in combination with d=Y
27
--- www/changes.wiki
+++ www/changes.wiki
@@ -17,10 +17,12 @@
17 * Improve defense against denial-of-service with repeated requests that
18 contain SQL injection attempts.
19 * Enhance file listings by displaying file sizes and allowing to sort by them.
20 * The [/help?cmd=fts-config|fossil fts-config] command now shows how much
21 repository space is used by the full-text index.
22 * The [/help?cmd=branch|fossil branch list] command can now filter branches
23 that have/have not been merged into the current branch.
24
25
26 <h2 id='v2_22'>Changes for version 2.22 (2023-05-31)</h2>
27 * Enhancements to the [/help?cmd=/timeline|/timeline webpage]: <ol type="a">
28 <li> Add the ft=TAG query parameter which in combination with d=Y
29
--- www/changes.wiki
+++ www/changes.wiki
@@ -17,10 +17,12 @@
1717
* Improve defense against denial-of-service with repeated requests that
1818
contain SQL injection attempts.
1919
* Enhance file listings by displaying file sizes and allowing to sort by them.
2020
* The [/help?cmd=fts-config|fossil fts-config] command now shows how much
2121
repository space is used by the full-text index.
22
+ * The [/help?cmd=branch|fossil branch list] command can now filter branches
23
+ that have/have not been merged into the current branch.
2224
2325
2426
<h2 id='v2_22'>Changes for version 2.22 (2023-05-31)</h2>
2527
* Enhancements to the [/help?cmd=/timeline|/timeline webpage]: <ol type="a">
2628
<li> Add the ft=TAG query parameter which in combination with d=Y
2729
--- www/changes.wiki
+++ www/changes.wiki
@@ -17,10 +17,12 @@
17 * Improve defense against denial-of-service with repeated requests that
18 contain SQL injection attempts.
19 * Enhance file listings by displaying file sizes and allowing to sort by them.
20 * The [/help?cmd=fts-config|fossil fts-config] command now shows how much
21 repository space is used by the full-text index.
 
 
22
23
24 <h2 id='v2_22'>Changes for version 2.22 (2023-05-31)</h2>
25 * Enhancements to the [/help?cmd=/timeline|/timeline webpage]: <ol type="a">
26 <li> Add the ft=TAG query parameter which in combination with d=Y
27
--- www/changes.wiki
+++ www/changes.wiki
@@ -17,10 +17,12 @@
17 * Improve defense against denial-of-service with repeated requests that
18 contain SQL injection attempts.
19 * Enhance file listings by displaying file sizes and allowing to sort by them.
20 * The [/help?cmd=fts-config|fossil fts-config] command now shows how much
21 repository space is used by the full-text index.
22 * The [/help?cmd=branch|fossil branch list] command can now filter branches
23 that have/have not been merged into the current branch.
24
25
26 <h2 id='v2_22'>Changes for version 2.22 (2023-05-31)</h2>
27 * Enhancements to the [/help?cmd=/timeline|/timeline webpage]: <ol type="a">
28 <li> Add the ft=TAG query parameter which in combination with d=Y
29

Keyboard Shortcuts

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