public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: "VALERI Yoann via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>,
	Junio C Hamano <gitster@pobox.com>,
	Yoann Valeri <yoann.valeri@cea.fr>,
	Yoann Valeri <yoann.valeri@cea.fr>,
	VALERI Yoann <yoann.valeri@cea.fr>
Subject: [PATCH v2 2/2] branch: add a no-prefix option
Date: Fri, 27 Feb 2026 15:48:53 +0000	[thread overview]
Message-ID: <0fbdf031cb9f054e023d44fd3eb3315732d527c0.1772207333.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2202.v2.git.git.1772207333.gitgitgadget@gmail.com>

From: VALERI Yoann <yoann.valeri@cea.fr>

This patch adds a '--no-prefix' option to 'git branch' to selectively
override the 'branch.addCurrentBranchAsPrefix' configuration parameter.
Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
---
 builtin/branch.c  | 9 +++++++--
 t/t3200-branch.sh | 4 +++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 2fbf2d9722..701c2a3180 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -713,7 +713,8 @@ int cmd_branch(int argc,
 {
 	/* possible actions */
 	int delete = 0, rename = 0, copy = 0, list = 0,
-	    unset_upstream = 0, show_current = 0, edit_description = 0;
+	    unset_upstream = 0, show_current = 0, edit_description = 0,
+	    no_prefix = 0;
 	const char *new_upstream = NULL;
 	int noncreate_actions = 0;
 	/* possible options */
@@ -776,6 +777,7 @@ int cmd_branch(int argc,
 		OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
 		OPT_BOOL(0, "recurse-submodules", &recurse_submodules_explicit, N_("recurse through submodules")),
 		OPT_STRING(  0 , "format", &format.format, N_("format"), N_("format to use for the output")),
+		OPT_BOOL(0, "no-prefix", &no_prefix, N_("do not add a prefix to the branch being created")),
 		OPT_END(),
 	};
 
@@ -1004,7 +1006,10 @@ int cmd_branch(int argc,
 		if (track == BRANCH_TRACK_OVERRIDE)
 			die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead"));
 
-		add_branch_prefix(start_name, branch_name, &new_branch_name);
+		if (!no_prefix)
+			add_branch_prefix(start_name, branch_name, &new_branch_name);
+		else
+			strbuf_addstr(&new_branch_name, branch_name);
 
 		if (recurse_submodules)
 			create_branches_recursively(the_repository, new_branch_name.buf,
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 496b034d0b..bc09abf725 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1725,9 +1725,11 @@ test_expect_success 'create branch with prefix' '
 	git branch branch-with-prefix &&
 	git checkout branch-with-prefix &&
 	git branch branch-with-prefix &&
+	git branch branch-with-no-prefix --no-prefix &&
 	test_ref_exists refs/heads/branch-with-prefix &&
 	test_ref_exists refs/heads/main-branch-with-prefix &&
-	test_ref_exists refs/heads/branch-with-prefix-branch-with-prefix
+	test_ref_exists refs/heads/branch-with-prefix-branch-with-prefix &&
+	test_ref_exists refs/heads/branch-with-no-prefix
 '
 
 test_done
-- 
gitgitgadget

  parent reply	other threads:[~2026-02-27 15:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20  8:07 [PATCH] branch: add 'branch.addCurrentBranchAsPrefix' config param Yoann Valeri via GitGitGadget
2026-02-20 15:59 ` Junio C Hamano
2026-02-20 16:08 ` Junio C Hamano
2026-02-27 15:48 ` [PATCH v2 0/2] " Yoann Valeri via GitGitGadget
2026-02-27 15:48   ` [PATCH v2 1/2] " VALERI Yoann via GitGitGadget
2026-02-27 15:48   ` VALERI Yoann via GitGitGadget [this message]
2026-02-27 17:07     ` [PATCH v2 2/2] branch: add a no-prefix option Junio C Hamano
2026-03-06 13:14   ` [PATCH v3 0/3] branch: add prefixes to new branch names Yoann Valeri via GitGitGadget
2026-03-06 13:14     ` [PATCH v3 1/3] branch: add '--name-prefix' option VALERI Yoann via GitGitGadget
2026-03-07  7:06       ` Eric Sunshine
2026-03-08  7:06       ` Junio C Hamano
2026-03-06 13:14     ` [PATCH v3 2/3] branch: add 'branch.namePrefix' config param VALERI Yoann via GitGitGadget
2026-03-07  7:07       ` Eric Sunshine
2026-03-06 13:14     ` [PATCH v3 3/3] branch: add '--no-name-prefix' option VALERI Yoann via GitGitGadget
2026-03-06 21:38       ` Junio C Hamano
2026-03-06 21:01     ` [PATCH v3 0/3] branch: add prefixes to new branch names Junio C Hamano
2026-03-07  7:05     ` Eric Sunshine
2026-03-08  6:48       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0fbdf031cb9f054e023d44fd3eb3315732d527c0.1772207333.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ps@pks.im \
    --cc=yoann.valeri@cea.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox