All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] am: Fix broken guessbranch handling
@ 2022-03-31 19:53 Rob Herring
  2022-06-14 20:25 ` Konstantin Ryabitsev
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2022-03-31 19:53 UTC (permalink / raw)
  To: tools

b4's usage of git-log '--branches' option is broken. The option takes a
glob pattern *only* and must have an '=', but b4 ends up passing
'--branches <guessbranch>' to git-log. This will kind of work, but is
not checking only 'guessbranch'. For example, these 3 commands all do
something different:

git log -1 --branches=master

git log -1 --branches master

git log -1 --branches=*aster

A maintainer wanting to apply a patch or series likely has a small set of
known branches they apply patches to. Using a glob pattern is not a good
fit for that. Instead, allow --guess-branch to be repeated and to take
fixed refs.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 b4/__init__.py | 4 ++--
 b4/command.py  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/b4/__init__.py b/b4/__init__.py
index ec1a6da44144..be934e53ca0d 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -643,7 +643,7 @@ class LoreSeries:
 
         return len(self.indexes), mismatches
 
-    def find_base(self, gitdir: str, branches: Optional[str] = None, maxdays: int = 30) -> Tuple[str, len, len]:
+    def find_base(self, gitdir: str, branches: Optional[list] = None, maxdays: int = 30) -> Tuple[str, len, len]:
         # Find the date of the first patch we have
         pdate = datetime.datetime.now()
         for lmsg in self.patches:
@@ -655,7 +655,7 @@ class LoreSeries:
         # Find latest commit on that date
         guntil = pdate.strftime('%Y-%m-%d')
         if branches:
-            where = ['--branches', branches]
+            where = branches
         else:
             where = ['--all']
 
diff --git a/b4/command.py b/b4/command.py
index 3a2d58f364e5..6d3c899480ec 100644
--- a/b4/command.py
+++ b/b4/command.py
@@ -133,7 +133,7 @@ def cmd():
                        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', default=None,
+    sp_am.add_argument('-b', '--guess-branch', dest='guessbranch', nargs='+', 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)')
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] am: Fix broken guessbranch handling
  2022-03-31 19:53 [PATCH] am: Fix broken guessbranch handling Rob Herring
@ 2022-06-14 20:25 ` Konstantin Ryabitsev
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Ryabitsev @ 2022-06-14 20:25 UTC (permalink / raw)
  To: robh, tools

On Thu, 31 Mar 2022 14:53:46 -0500, Rob Herring wrote:
> b4's usage of git-log '--branches' option is broken. The option takes a
> glob pattern *only* and must have an '=', but b4 ends up passing
> '--branches <guessbranch>' to git-log. This will kind of work, but is
> not checking only 'guessbranch'. For example, these 3 commands all do
> something different:
> 
> git log -1 --branches=master
> 
> [...]

Applied, thanks!

[1/1] am: Fix broken guessbranch handling
      commit: c95e4d16d87c7c71589c64b1ac94973b354d0820

Best regards,
-- 
Konstantin Ryabitsev <konstantin@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-14 20:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 19:53 [PATCH] am: Fix broken guessbranch handling Rob Herring
2022-06-14 20:25 ` Konstantin Ryabitsev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.