diff mbox series

[b4] b4: Allow prep new branch while on a b4 managed branch

Message ID 20230517-allow-new-w-fork-point-v1-1-22d2cb938e16@intel.com (mailing list archive)
State Accepted
Headers show
Series [b4] b4: Allow prep new branch while on a b4 managed branch | expand

Commit Message

Ira Weiny May 17, 2023, 6:56 p.m. UTC
Creating a new branch from a specified fork point should be allowed when
sitting on a b4 managed branch.  For example this fails:

	$ b4 prep -n foo -f master
	Created new branch b4/foo
	Created the default cover letter, you can edit with --edit-cover.

	$ b4 prep -n bar -f master
	CRITICAL: This appears to already be a b4-prep managed branch.

Allow a specified fork point to be used regardless of the b4 state of
the current branch.

Make -n and -e options mutually exclusive early on to clarify the
difference between them in practical usage.

With this change the following works as expected.

	$ git co b4/allow-new-w-fork-point
	Switched to branch 'b4/allow-new-w-fork-point'

	$ b4 prep -n bar -f master
	Created new branch b4/bar
	Created the default cover letter, you can edit with --edit-cover.

	$ b4 prep -n foobar -e master -f master
	CRITICAL: -n NEW_SERIES_NAME and -e [ENROLL_BASE] can not be used together.

Cc: tools@linux.kernel.org
Cc: konstantin@linuxfoundation.org
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 b4/ez.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)


---
base-commit: bfdf5b3b0835c8c351abbcd9b3b5268acf6545fa
change-id: 20230517-allow-new-w-fork-point-f64d56c5c086

Best regards,

Comments

Konstantin Ryabitsev May 26, 2023, 5:49 p.m. UTC | #1
On Wed, 17 May 2023 11:56:38 -0700, Ira Weiny wrote:
> Creating a new branch from a specified fork point should be allowed when
> sitting on a b4 managed branch.  For example this fails:
> 
> 	$ b4 prep -n foo -f master
> 	Created new branch b4/foo
> 	Created the default cover letter, you can edit with --edit-cover.
> 
> [...]

Applied, thanks!

[1/1] b4: Allow prep new branch while on a b4 managed branch
      commit: 229b766fdd3b9d5561e76a5cf569aa946dcc2ef0

Best regards,
diff mbox series

Patch

diff --git a/b4/ez.py b/b4/ez.py
index 47fafc1325f0..d0c06679c143 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -2186,8 +2186,12 @@  def cmd_prep(cmdargs: argparse.Namespace) -> None:
     if cmdargs.compare_to:
         return compare(cmdargs.compare_to)
 
+    if cmdargs.enroll_base and cmdargs.new_series_name:
+        logger.critical('CRITICAL: -n NEW_SERIES_NAME and -e [ENROLL_BASE] can not be used together.')
+        sys.exit(1)
+
     if cmdargs.enroll_base or cmdargs.new_series_name:
-        if is_prep_branch():
+        if is_prep_branch() and not cmdargs.fork_point:
             logger.critical('CRITICAL: This appears to already be a b4-prep managed branch.')
             sys.exit(1)