Skip to contentSkip to conversation

Limit --guess-branch argument to 1 branch

PATCH New Rob Herring (Arm) 1 participant 2 messages Jan 8, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Limit --guess-branch argument to 1 branch

More than 1 branch argument doesn't work correctly, so restrict it to 1 arg. The help text already implies it is a single branch.

---
 src/b4/command.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/b4/command.py +1 -1
index 5d90b4f52b4f..e31ee052c9cd 100644
@@ -184,7 +184,7 @@ def setup_parser() -> argparse.ArgumentParser:
                        help='Save patches in a quilt-ready folder')
     sp_am.add_argument('-g', '--guess-base', dest='guessbase', action='store_true', default=False,
                        help='Try to guess the base of the series (if not specified)')
-    sp_am.add_argument('-b', '--guess-branch', dest='guessbranch', nargs='+', action='extend', type=str, default=None,
+    sp_am.add_argument('-b', '--guess-branch', dest='guessbranch', nargs=1, action='extend', type=str, default=None,
                        help='When guessing base, restrict to this branch (use with -g)')
     sp_am.add_argument('--guess-lookback', dest='guessdays', type=int, default=21,
                        help='When guessing base, go back this many days from the patch date (default: 2 weeks)')
Signature · 1 line
2.45.2
#1 lore raw

PATCH 2/2 Allow --guess-branch argument with shazam -H/-M options

For the b4 shazam cases which create a FETCH_HEAD, it's useful to be able to specify the branch to use for guessing the base commit rather than just using HEAD.

---
 src/b4/command.py | 2 ++
 src/b4/mbox.py    | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
src/b4/command.py +2 -0
index e31ee052c9cd..99854e9932c0 100644
@@ -206,6 +206,8 @@ def setup_parser() -> argparse.ArgumentParser:
                       help='Attempt to treat series as a pull request and fetch it into FETCH_HEAD')
     sh_g.add_argument('-M', '--merge', dest='merge', action='store_true', default=False,
                       help='Attempt to merge series as if it were a pull request (execs git-merge)')
+    sp_sh.add_argument('-b', '--guess-branch', dest='guessbranch', nargs=1, action='extend', type=str, default=None,
+                       help='(use with -H or -M) When guessing base, restrict to this branch (use with -g)')
     sp_sh.add_argument('--guess-lookback', dest='guessdays', type=int, default=21,
                        help=('(use with -H or -M) When guessing base, go back this many days from the patch date '
                              '(default: 3 weeks)'))
src/b4/mbox.py +1 -1
index 7061d1493be3..768a896904ad 100644
@@ -783,13 +783,13 @@ def main(cmdargs: argparse.Namespace) -> None:
         cmdargs.threeway = False
         cmdargs.nopartialreroll = False
         cmdargs.outdir = '-'
-        cmdargs.guessbranch = None
         if cmdargs.merge:
             cmdargs.makefetchhead = True
         if cmdargs.makefetchhead:
             cmdargs.guessbase = True
         else:
             cmdargs.guessbase = False
+            cmdargs.guessbranch = None
     else:
         cmdargs.mergebase = False
 
Signature · 1 line
2.45.2