tools.linux.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH b4 RFC 0/3] "b4 prep --new --fork-point" is not clear to me
@ 2023-02-06 18:23 Matthieu Baerts
  2023-02-06 18:23 ` [PATCH b4 RFC 1/3] ez: prep -n: use fork-point as base branch Matthieu Baerts
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matthieu Baerts @ 2023-02-06 18:23 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Matthieu Baerts, Konstantin Ryabitsev

This is an RFC because when looking at the code, I'm not sure I'm using
this command properly.

For me, using '--fork-point' is useful to avoid switching to another
branch before calling 'b4 prep -n', no? On my side, it is especially
useful if this other branch is not a local one, e.g.

  b4 prep -n foo -f linus/master

It seems doing what I want by creating the new b4 branch on top of
'linus/master' one. Except that b4 was using the current branch as 'base
branch'.

I thought it was a bug and I just changed the line that was problematic
for me (patch 1).

But when I looked at the code just above, I didn't find a reason why
the current branch is also used there with the other strategies. I'm
sure I'm missing something there but just in case, I did this
modification (patch 2). Maybe all we need is to make sure the given
argument is a branch (patch 3)?

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
Matthieu Baerts (3):
      ez: prep -n: use fork-point as base branch
      ez: prep -n: always use fork-point as a base
      ez: prep -n: validate fork-point is a branch

 b4/ez.py | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)
---
base-commit: ada3021c64dd484e53219eb3af55da6c8f25d0ec
change-id: 20230206-b4-prep-fork-point-as-base-branch-377bb2b2dd68

Best regards,
-- 
Matthieu Baerts <matthieu.baerts@tessares.net>


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

* [PATCH b4 RFC 1/3] ez: prep -n: use fork-point as base branch
  2023-02-06 18:23 [PATCH b4 RFC 0/3] "b4 prep --new --fork-point" is not clear to me Matthieu Baerts
@ 2023-02-06 18:23 ` Matthieu Baerts
  2023-02-06 18:23 ` [PATCH b4 RFC 2/3] ez: prep -n: always use fork-point as a base Matthieu Baerts
  2023-02-06 18:23 ` [PATCH b4 RFC 3/3] ez: prep -n: validate fork-point is a branch Matthieu Baerts
  2 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2023-02-06 18:23 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Matthieu Baerts, Konstantin Ryabitsev

When creating a new branch with a fork point, use it as base branch.

Without that, when using:

  b4 prep -n ${NEW_SERIES_NAME} -f ${FORK_POINT}

The branch ${NEW_SERIES_NAME} will be created on top of ${FORK_POINT}
but the current branch will be set as base branch. ${FORK_POINT} can be
quite different from the current branch.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 b4/ez.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/b4/ez.py b/b4/ez.py
index 74afddc..2722c6c 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -345,7 +345,7 @@ def start_new_series(cmdargs: argparse.Namespace) -> None:
                         basebranch = mybranch
                         break
             else:
-                basebranch = mybranch
+                basebranch = cmdargs.fork_point
 
             if basebranch is None:
                 logger.critical('CRITICAL: fork-point %s is not on the current branch.', cmdargs.fork_point)

-- 
2.38.1


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

* [PATCH b4 RFC 2/3] ez: prep -n: always use fork-point as a base
  2023-02-06 18:23 [PATCH b4 RFC 0/3] "b4 prep --new --fork-point" is not clear to me Matthieu Baerts
  2023-02-06 18:23 ` [PATCH b4 RFC 1/3] ez: prep -n: use fork-point as base branch Matthieu Baerts
@ 2023-02-06 18:23 ` Matthieu Baerts
  2023-02-06 18:23 ` [PATCH b4 RFC 3/3] ez: prep -n: validate fork-point is a branch Matthieu Baerts
  2 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2023-02-06 18:23 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Matthieu Baerts, Konstantin Ryabitsev

It is unclear to me why the current branch is used when 'fork point'
argument is given in the other strategies.

The explanation of the --fork-point option seems to suggest that this
fork point is will be the new base branch instead of HEAD. Then there is
no reason to look at the current branch which can be something totally
different.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 b4/ez.py | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/b4/ez.py b/b4/ez.py
index 2722c6c..9200d03 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -328,29 +328,7 @@ def start_new_series(cmdargs: argparse.Namespace) -> None:
             cmdargs.fork_point = 'HEAD'
             basebranch = mybranch
         else:
-            # if our strategy is not "commit", then we need to know which branch we're using as base
-            if strategy != 'commit':
-                gitargs = ['branch', '-v', '--contains', cmdargs.fork_point]
-                lines = b4.git_get_command_lines(None, gitargs)
-                if not lines:
-                    logger.critical('CRITICAL: no branch contains fork-point %s', cmdargs.fork_point)
-                    sys.exit(1)
-                for line in lines:
-                    chunks = line.split(maxsplit=2)
-                    # There's got to be a better way than checking for '*'
-                    if chunks[0] != '*':
-                        continue
-                    if chunks[1] == mybranch:
-                        logger.debug('branch %s does contain fork-point %s', mybranch, cmdargs.fork_point)
-                        basebranch = mybranch
-                        break
-            else:
-                basebranch = cmdargs.fork_point
-
-            if basebranch is None:
-                logger.critical('CRITICAL: fork-point %s is not on the current branch.', cmdargs.fork_point)
-                logger.critical('          Switch to the branch you want to use as base and try again.')
-                sys.exit(1)
+            basebranch = cmdargs.fork_point
 
         slug = re.sub(r'\W+', '-', cmdargs.new_series_name).strip('-').lower()
         branchname = 'b4/%s' % slug

-- 
2.38.1


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

* [PATCH b4 RFC 3/3] ez: prep -n: validate fork-point is a branch
  2023-02-06 18:23 [PATCH b4 RFC 0/3] "b4 prep --new --fork-point" is not clear to me Matthieu Baerts
  2023-02-06 18:23 ` [PATCH b4 RFC 1/3] ez: prep -n: use fork-point as base branch Matthieu Baerts
  2023-02-06 18:23 ` [PATCH b4 RFC 2/3] ez: prep -n: always use fork-point as a base Matthieu Baerts
@ 2023-02-06 18:23 ` Matthieu Baerts
  2 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2023-02-06 18:23 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Matthieu Baerts, Konstantin Ryabitsev

This --fork-point option is used to set the new base branch.

Make then sure it is one and not a fixed SHA.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 b4/ez.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/b4/ez.py b/b4/ez.py
index 9200d03..8d90296 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -330,6 +330,12 @@ def start_new_series(cmdargs: argparse.Namespace) -> None:
         else:
             basebranch = cmdargs.fork_point
 
+            gitargs = ['show-ref', '--quiet', basebranch]
+            ecode, out = b4.git_run_command(None, gitargs)
+            if ecode > 0:
+                logger.critical('CRITICAL: fork-point %s is not a branch', basebranch)
+                sys.exit(1)
+
         slug = re.sub(r'\W+', '-', cmdargs.new_series_name).strip('-').lower()
         branchname = 'b4/%s' % slug
         args = ['checkout', '-b', branchname, cmdargs.fork_point]

-- 
2.38.1


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

end of thread, other threads:[~2023-02-06 18:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06 18:23 [PATCH b4 RFC 0/3] "b4 prep --new --fork-point" is not clear to me Matthieu Baerts
2023-02-06 18:23 ` [PATCH b4 RFC 1/3] ez: prep -n: use fork-point as base branch Matthieu Baerts
2023-02-06 18:23 ` [PATCH b4 RFC 2/3] ez: prep -n: always use fork-point as a base Matthieu Baerts
2023-02-06 18:23 ` [PATCH b4 RFC 3/3] ez: prep -n: validate fork-point is a branch Matthieu Baerts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).