Fossil

Check-in [8ff63db2e6]
Login

Check-in [8ff63db2e6]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the ability for 'branch list' to filter the branches that have/have not been merged into the current branch.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8ff63db2e66013a5b6dc8108bb874dea48c48f8892b5f4762e7771b29ee662aa
User & Date: danield 2023-09-14 08:25:16.813
Context
2023-09-18
20:43
Merge the CSRF-defense enhancements into trunk. ... (check-in: 920ace1739 user: drh tags: trunk)
13:18
Try to simplify and rationalize the defenses against cross-site request forgery attacks. A hodgepodge of techniques have been used in the past. This changes attempts to make everything work more alike and to centralize CSRF defenses for easier auditing. ... (check-in: 88a402fe2a user: drh tags: csrf-defense-enhancement)
2023-09-14
08:25
Add the ability for 'branch list' to filter the branches that have/have not been merged into the current branch. ... (check-in: 8ff63db2e6 user: danield tags: trunk)
08:04
Update the built-in SQLite to version 3.43.1. ... (check-in: 1fea5c2ce9 user: danield tags: trunk)
2023-06-14
14:37
Add the ability for 'branch list' to filter the branches that have/have not been merged into the current branch, per [forum:c4a9d9e097|forum request]. ... (Closed-Leaf check-in: d6ddd5bcfa user: danield tags: branch-list-merged-unmerged)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/branch.c.
274
275
276
277
278
279
280


281
282
283
284
285
286
287
#define BRL_CLOSED_ONLY      0x001 /* Show only closed branches */
#define BRL_OPEN_ONLY        0x002 /* Show only open branches */
#define BRL_BOTH             0x003 /* Show both open and closed branches */
#define BRL_OPEN_CLOSED_MASK 0x003
#define BRL_ORDERBY_MTIME    0x004 /* Sort by MTIME. (otherwise sort by name)*/
#define BRL_REVERSE          0x008 /* Reverse the sort order */
#define BRL_PRIVATE          0x010 /* Show only private branches */



#endif /* INTERFACE */

/*
** Prepare a query that will list branches.
**
** If the BRL_ORDERBY_MTIME flag is set and nLimitMRU ("Limit Most Recently Used







>
>







274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#define BRL_CLOSED_ONLY      0x001 /* Show only closed branches */
#define BRL_OPEN_ONLY        0x002 /* Show only open branches */
#define BRL_BOTH             0x003 /* Show both open and closed branches */
#define BRL_OPEN_CLOSED_MASK 0x003
#define BRL_ORDERBY_MTIME    0x004 /* Sort by MTIME. (otherwise sort by name)*/
#define BRL_REVERSE          0x008 /* Reverse the sort order */
#define BRL_PRIVATE          0x010 /* Show only private branches */
#define BRL_MERGED           0x020 /* Show only merged branches */
#define BRL_UNMERGED         0x040 /* Show only unmerged branches */

#endif /* INTERFACE */

/*
** Prepare a query that will list branches.
**
** If the BRL_ORDERBY_MTIME flag is set and nLimitMRU ("Limit Most Recently Used
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331

332
333
334
335
336
337
338
  blob_init(&sql, 0, 0);
  brlist_create_temp_table();
  /* Ignore nLimitMRU if no chronological sort requested. */
  if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
  /* Undocumented: invert negative values for nLimitMRU, so that command-line
  ** arguments similar to `head -5' with "option numbers" are possible. */
  if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
  blob_append_sql(&sql,"SELECT name, isprivate FROM ("); /* OUTER QUERY */
  switch( brFlags & BRL_OPEN_CLOSED_MASK ){
    case BRL_CLOSED_ONLY: {
      blob_append_sql(&sql,
        "SELECT name, isprivate, mtime FROM tmp_brlist WHERE isclosed"
      );
      break;
    }
    case BRL_BOTH: {
      blob_append_sql(&sql,
        "SELECT name, isprivate, mtime FROM tmp_brlist WHERE 1"
      );
      break;
    }
    case BRL_OPEN_ONLY: {
      blob_append_sql(&sql,
        "SELECT name, isprivate, mtime FROM tmp_brlist WHERE NOT isclosed"
      );
      break;
    }
  }
  if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");

  if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
  if( brFlags & BRL_ORDERBY_MTIME ){
    blob_append_sql(&sql, " ORDER BY -mtime");
  }else{
    blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
  }
  if( brFlags & BRL_REVERSE && !nLimitMRU ){







|



|





|





|





>







305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
  blob_init(&sql, 0, 0);
  brlist_create_temp_table();
  /* Ignore nLimitMRU if no chronological sort requested. */
  if( (brFlags & BRL_ORDERBY_MTIME)==0 ) nLimitMRU = 0;
  /* Undocumented: invert negative values for nLimitMRU, so that command-line
  ** arguments similar to `head -5' with "option numbers" are possible. */
  if( nLimitMRU<0 ) nLimitMRU = -nLimitMRU;
  blob_append_sql(&sql,"SELECT name, isprivate, mergeto FROM ("); /* OUTER QUERY */
  switch( brFlags & BRL_OPEN_CLOSED_MASK ){
    case BRL_CLOSED_ONLY: {
      blob_append_sql(&sql,
        "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE isclosed"
      );
      break;
    }
    case BRL_BOTH: {
      blob_append_sql(&sql,
        "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE 1"
      );
      break;
    }
    case BRL_OPEN_ONLY: {
      blob_append_sql(&sql,
        "SELECT name, isprivate, mtime, mergeto FROM tmp_brlist WHERE NOT isclosed"
      );
      break;
    }
  }
  if( brFlags & BRL_PRIVATE ) blob_append_sql(&sql, " AND isprivate");
  if( brFlags & BRL_MERGED ) blob_append_sql(&sql, " AND mergeto IS NOT NULL");
  if(zBrNameGlob) blob_append_sql(&sql, " AND (name GLOB %Q)", zBrNameGlob);
  if( brFlags & BRL_ORDERBY_MTIME ){
    blob_append_sql(&sql, " ORDER BY -mtime");
  }else{
    blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
  }
  if( brFlags & BRL_REVERSE && !nLimitMRU ){
611
612
613
614
615
616
617


618
619
620
621
622
623
624
** >  fossil branch lsh ?OPTIONS? ?LIMIT?
**
**        List all branches.
**
**        Options:
**          -a|--all      List all branches.  Default show only open branches
**          -c|--closed   List closed branches


**          -p            List only private branches
**          -r            Reverse the sort order
**          -t            Show recently changed branches first
**
**        The current branch is marked with an asterisk.  Private branches are
**        marked with a hash sign.
**







>
>







614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
** >  fossil branch lsh ?OPTIONS? ?LIMIT?
**
**        List all branches.
**
**        Options:
**          -a|--all      List all branches.  Default show only open branches
**          -c|--closed   List closed branches
**          -m|--merged   List branches merged into the current branch
**          -M|--unmerged List branches not merged into the current branch
**          -p            List only private branches
**          -r            Reverse the sort order
**          -t            Show recently changed branches first
**
**        The current branch is marked with an asterisk.  Private branches are
**        marked with a hash sign.
**
692
693
694
695
696
697
698


699



700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718

719







720
721
722
723
724
725
726
    int nLimit = 0;
    int brFlags = BRL_OPEN_ONLY;
    if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
    if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
    if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
    if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
    if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;






    if( strcmp(zCmd, "lsh")==0 ){
      nLimit = 5;
      if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
        fossil_fatal("the lsh subcommand allows one optional numeric argument");
      }
      brFlags |= BRL_ORDERBY_MTIME;
    }else{
      if( g.argc >= 4 ) zBrNameGlob = g.argv[3];
    }

    if( g.localOpen ){
      vid = db_lget_int("checkout", 0);
      zCurrent = db_text(0, "SELECT value FROM tagxref"
                            " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
    }
    branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
    while( db_step(&q)==SQLITE_ROW ){
      const char *zBr = db_column_text(&q, 0);
      int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;

      int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;







      fossil_print("%s%s%s\n",
        ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
        (isCur ? "* " : "  "), zBr);
    }
    db_finalize(&q);
  }else if( strncmp(zCmd,"new",n)==0 ){
    branch_new();







>
>

>
>
>



















>

>
>
>
>
>
>
>







697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
    int nLimit = 0;
    int brFlags = BRL_OPEN_ONLY;
    if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
    if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
    if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
    if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
    if( find_option("p",0,0)!=0 ) brFlags |= BRL_PRIVATE;
    if( find_option("merged","m",0)!=0 ) brFlags |= BRL_MERGED;
    if( find_option("unmerged","M",0)!=0 ) brFlags |= BRL_UNMERGED;

    if ( (brFlags & BRL_MERGED) && (brFlags & BRL_UNMERGED) ){
      fossil_fatal("flags --merged and --unmerged are mutually exclusive");
    }
    if( strcmp(zCmd, "lsh")==0 ){
      nLimit = 5;
      if( g.argc>4 || (g.argc==4 && (nLimit = atoi(g.argv[3]))==0) ){
        fossil_fatal("the lsh subcommand allows one optional numeric argument");
      }
      brFlags |= BRL_ORDERBY_MTIME;
    }else{
      if( g.argc >= 4 ) zBrNameGlob = g.argv[3];
    }

    if( g.localOpen ){
      vid = db_lget_int("checkout", 0);
      zCurrent = db_text(0, "SELECT value FROM tagxref"
                            " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
    }
    branch_prepare_list_query(&q, brFlags, zBrNameGlob, nLimit);
    while( db_step(&q)==SQLITE_ROW ){
      const char *zBr = db_column_text(&q, 0);
      int isPriv = zCurrent!=0 && db_column_int(&q, 1)==1;
      const char *zMergeTo = db_column_text(&q, 2);
      int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
      if( (brFlags & BRL_MERGED) && fossil_strcmp(zCurrent,zMergeTo)!=0 ){
        continue;
      }
      if( (brFlags & BRL_UNMERGED) && (fossil_strcmp(zCurrent,zMergeTo)==0 
          || isCur) ){
        continue;
      }
      fossil_print("%s%s%s\n",
        ( (brFlags & BRL_PRIVATE) ? " " : ( isPriv ? "#" : " ") ),
        (isCur ? "* " : "  "), zBr);
    }
    db_finalize(&q);
  }else if( strncmp(zCmd,"new",n)==0 ){
    branch_new();
Changes to www/changes.wiki.
15
16
17
18
19
20
21


22
23
24
25
26
27
28
  *  Fix a regression bug introduced in version 2.22 that caused FTS5 searches
     to fail for terms containing non-ASCII characters.
  *  Improve defense against denial-of-service with repeated requests that
     contain SQL injection attempts.
  *  Enhance file listings by displaying file sizes and allowing to sort by them.
  *  The [/help?cmd=fts-config|fossil fts-config] command now shows how much
     repository space is used by the full-text index.




<h2 id='v2_22'>Changes for version 2.22 (2023-05-31)</h2>
  *  Enhancements to the [/help?cmd=/timeline|/timeline webpage]: <ol type="a">
     <li> Add the ft=TAG query parameter which in combination with d=Y
          shows all descendants of Y up to TAG
     <li> Enhance the s=PATTERN (search) query parameter so that forum post







>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  *  Fix a regression bug introduced in version 2.22 that caused FTS5 searches
     to fail for terms containing non-ASCII characters.
  *  Improve defense against denial-of-service with repeated requests that
     contain SQL injection attempts.
  *  Enhance file listings by displaying file sizes and allowing to sort by them.
  *  The [/help?cmd=fts-config|fossil fts-config] command now shows how much
     repository space is used by the full-text index.
  *  The [/help?cmd=branch|fossil branch list] command can now filter branches
     that have/have not been merged into the current branch.


<h2 id='v2_22'>Changes for version 2.22 (2023-05-31)</h2>
  *  Enhancements to the [/help?cmd=/timeline|/timeline webpage]: <ol type="a">
     <li> Add the ft=TAG query parameter which in combination with d=Y
          shows all descendants of Y up to TAG
     <li> Enhance the s=PATTERN (search) query parameter so that forum post