* [PATCH] branch: add 'branch.addCurrentBranchAsPrefix' config param
@ 2026-02-20 8:07 Yoann Valeri via GitGitGadget
2026-02-20 15:59 ` Junio C Hamano
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Yoann Valeri via GitGitGadget @ 2026-02-20 8:07 UTC (permalink / raw)
To: git; +Cc: Patrick Steinhardt, Yoann Valeri, VALERI Yoann
From: VALERI Yoann <yoann.valeri@cea.fr>
This patch adds a new configuration parameter for the branch creation
feature: 'branch.addCurrentBranchAsPrefix'. When set to true, if one
creates a new branch with either `git branch`, `git checkout -[bB]` or
`git switch -[cC]`, we will now retrieve the current branch's name, and
use it as prefix for the name of the newly created branch, alongside a
hyphen separating the two.
For instance, using this parameter, and attempting to create a branch
'test' while on the 'main' branch will instead create a branch
'main-test'.
This parameters is useful for projects handling many branches, with
features often needing backport on different branches, so as to reduce
the time taken to create branches without having to come up with clever
names.
Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
---
branch: add 'branch.addCurrentBranchAsPrefix' config param
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2202%2Fvaleriyoann%2Fbranch-with-prefix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2202/valeriyoann/branch-with-prefix-v1
Pull-Request: https://github.com/git/git/pull/2202
Documentation/config/branch.adoc | 7 +++++
branch.c | 14 +++++++++
branch.h | 8 +++++
builtin/branch.c | 17 ++++++-----
builtin/checkout.c | 52 +++++++++++++++++++++++---------
t/t2018-checkout-branch.sh | 26 ++++++++++++++++
t/t2060-switch.sh | 26 ++++++++++++++++
t/t3200-branch.sh | 14 +++++++++
8 files changed, 142 insertions(+), 22 deletions(-)
diff --git a/Documentation/config/branch.adoc b/Documentation/config/branch.adoc
index a4db9fa5c8..bd153ea406 100644
--- a/Documentation/config/branch.adoc
+++ b/Documentation/config/branch.adoc
@@ -35,6 +35,13 @@ This option defaults to `never`.
value of this variable will be used as the default.
See linkgit:git-for-each-ref[1] field names for valid values.
+`branch.addCurrentBranchAsPrefix`::
+ When a new branch is created with `git branch`, `git switch` or `git
+ checkout` use the name of the current branch as a prefix for the new
+ branch's name, alongside the one provided by the user, with a hyphen in the
+ middle. For instance, using this configuration variable, creating the branch
+ `test` while on `main` will create the branch `main-test`. False by default.
+
`branch.<name>.remote`::
When on branch _<name>_, it tells `git fetch` and `git push`
which remote to fetch from or push to. The remote to push to
diff --git a/branch.c b/branch.c
index 243db7d0fc..f2d348b046 100644
--- a/branch.c
+++ b/branch.c
@@ -365,6 +365,20 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
return 0;
}
+void add_branch_prefix(const char *current_branch,
+ const char *target_branch, struct strbuf *buf)
+{
+ int value = 0;
+
+ repo_config_get_bool(the_repository,
+ "branch.addCurrentBranchAsPrefix", &value);
+
+ if (value)
+ strbuf_addf(buf, "%s-%s", current_branch, target_branch);
+ else
+ strbuf_addstr(buf, target_branch);
+}
+
/*
* Check if 'name' can be a valid name for a branch; die otherwise.
* Return 1 if the named branch already exists; return 0 otherwise.
diff --git a/branch.h b/branch.h
index ec2f35fda4..060de1b72c 100644
--- a/branch.h
+++ b/branch.h
@@ -148,6 +148,14 @@ int install_branch_config(int flag, const char *local, const char *origin, const
*/
int read_branch_desc(struct strbuf *, const char *branch_name);
+/*
+ * Fetch the configuration parameter 'branch.addCurrentBranchAsPrefix' and
+ * fill the buffer 'buf' with '<current_branch>-<target_branch>' if true,
+ * otherwise just '<current_branch>'.
+ */
+void add_branch_prefix(const char *current_branch,
+ const char *target_branch, struct strbuf *buf);
+
/*
* Check if a branch is checked out in the main worktree or any linked
* worktree and die (with a message describing its checkout location) if
diff --git a/builtin/branch.c b/builtin/branch.c
index c577b5d20f..2fbf2d9722 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -995,6 +995,7 @@ int cmd_branch(int argc,
} else if (!noncreate_actions && argc > 0 && argc <= 2) {
const char *branch_name = argv[0];
const char *start_name = argc == 2 ? argv[1] : head;
+ struct strbuf new_branch_name = STRBUF_INIT;
if (filter.kind != FILTER_REFS_BRANCHES)
die(_("the -a, and -r, options to 'git branch' do not take a branch name.\n"
@@ -1003,15 +1004,17 @@ 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"));
- if (recurse_submodules) {
- create_branches_recursively(the_repository, branch_name,
+ add_branch_prefix(start_name, branch_name, &new_branch_name);
+
+ if (recurse_submodules)
+ create_branches_recursively(the_repository, new_branch_name.buf,
start_name, NULL, force,
reflog, quiet, track, 0);
- ret = 0;
- goto out;
- }
- create_branch(the_repository, branch_name, start_name, force, 0,
- reflog, quiet, track, 0);
+ else
+ create_branch(the_repository, new_branch_name.buf, start_name,
+ force, 0, reflog, quiet, track, 0);
+
+ strbuf_release(&new_branch_name);
} else
usage_with_options(builtin_branch_usage, options);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0ba4f03f2e..950198d8f3 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1170,31 +1170,42 @@ static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne
release_revisions(&revs);
}
+static void get_current_branch_info(struct branch_info *branch_info)
+{
+ struct object_id rev;
+ int flag;
+
+ branch_info->path = refs_resolve_refdup(get_main_ref_store(the_repository),
+ "HEAD", 0, &rev, &flag);
+
+ if (branch_info->path)
+ branch_info->commit = lookup_commit_reference_gently(the_repository,
+ &rev, 1);
+
+ if (!(flag & REF_ISSYMREF))
+ FREE_AND_NULL(branch_info->path);
+
+ if (branch_info->path) {
+ const char *const prefix = "refs/heads/";
+ const char *p;
+
+ if (skip_prefix(branch_info->path, prefix, &p))
+ branch_info->name = xstrdup(p);
+ }
+}
+
static int switch_branches(const struct checkout_opts *opts,
struct branch_info *new_branch_info)
{
int ret = 0;
struct branch_info old_branch_info = { 0 };
- struct object_id rev;
- int flag, writeout_error = 0;
+ int writeout_error = 0;
int do_merge = 1;
trace2_cmd_mode("branch");
memset(&old_branch_info, 0, sizeof(old_branch_info));
- old_branch_info.path = refs_resolve_refdup(get_main_ref_store(the_repository),
- "HEAD", 0, &rev, &flag);
- if (old_branch_info.path)
- old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
- if (!(flag & REF_ISSYMREF))
- FREE_AND_NULL(old_branch_info.path);
-
- if (old_branch_info.path) {
- const char *const prefix = "refs/heads/";
- const char *p;
- if (skip_prefix(old_branch_info.path, prefix, &p))
- old_branch_info.name = xstrdup(p);
- }
+ get_current_branch_info(&old_branch_info);
if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {
if (new_branch_info->name)
@@ -1772,6 +1783,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
int parseopt_flags = 0;
struct branch_info new_branch_info = { 0 };
int ret;
+ struct strbuf full_branch_name = { 0 };
opts->overwrite_ignore = 1;
opts->prefix = prefix;
@@ -1962,7 +1974,15 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
}
if (opts->new_branch) {
+ struct branch_info current_branch = { 0 };
struct strbuf buf = STRBUF_INIT;
+ strbuf_init(&full_branch_name, 0);
+
+ get_current_branch_info(¤t_branch);
+ add_branch_prefix(current_branch.name, opts->new_branch,
+ &full_branch_name);
+ branch_info_release(¤t_branch);
+ opts->new_branch = full_branch_name.buf;
if (opts->new_branch_force)
opts->branch_exists = validate_branchname(opts->new_branch, &buf);
@@ -1981,6 +2001,8 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
clear_pathspec(&opts->pathspec);
free(opts->pathspec_from_file);
free(options);
+ if (full_branch_name.buf)
+ strbuf_release(&full_branch_name);
return ret;
}
diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh
index a48ebdbf4d..8345a509dc 100755
--- a/t/t2018-checkout-branch.sh
+++ b/t/t2018-checkout-branch.sh
@@ -285,4 +285,30 @@ test_expect_success 'checkout -b rejects an extra path argument' '
test_grep "Cannot update paths and switch to branch" err
'
+test_expect_success 'checkout -b with prefix is valid' '
+ git checkout -b main &&
+ git checkout -b checkoutb-with-prefix &&
+ git checkout main &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ test_must_fail git checkout -b checkoutb-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git checkout -b checkoutb-with-prefix &&
+ git checkout -b checkoutb-with-prefix &&
+ test_ref_exists refs/heads/checkoutb-with-prefix &&
+ test_ref_exists refs/heads/main-checkoutb-with-prefix &&
+ test_ref_exists refs/heads/main-checkoutb-with-prefix-checkoutb-with-prefix
+'
+
+test_expect_success 'checkout -B with prefix is valid' '
+ git checkout main &&
+ git checkout -B checkoutB-with-prefix &&
+ git checkout main &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ git checkout -B checkoutB-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git checkout -B checkoutB-with-prefix &&
+ test_ref_exists refs/heads/checkoutB-with-prefix &&
+ test_ref_exists refs/heads/checkoutB-with-prefix-checkoutB-with-prefix
+'
+
test_done
diff --git a/t/t2060-switch.sh b/t/t2060-switch.sh
index c91c4db936..458f8b9f3f 100755
--- a/t/t2060-switch.sh
+++ b/t/t2060-switch.sh
@@ -177,4 +177,30 @@ test_expect_success 'switch back when temporarily detached and checked out elsew
git -C wt2 switch --ignore-other-worktrees shared
'
+test_expect_success 'switch -c with prefix is valid' '
+ git switch main &&
+ git switch -c switchc-with-prefix &&
+ git checkout main &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ test_must_fail git switch -c switchc-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git switch -c switchc-with-prefix &&
+ git switch -c switchc-with-prefix &&
+ test_ref_exists refs/heads/switchc-with-prefix &&
+ test_ref_exists refs/heads/main-switchc-with-prefix &&
+ test_ref_exists refs/heads/main-switchc-with-prefix-switchc-with-prefix
+'
+
+test_expect_success 'switch -C with prefix is valid' '
+ git switch main &&
+ git switch -C switchC-with-prefix &&
+ git checkout main &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ git switch -C switchC-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git switch -C switchC-with-prefix &&
+ test_ref_exists refs/heads/switchC-with-prefix &&
+ test_ref_exists refs/heads/switchC-with-prefix-switchC-with-prefix
+'
+
test_done
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index c58e505c43..496b034d0b 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1716,4 +1716,18 @@ test_expect_success 'errors if given a bad branch name' '
test_cmp expect actual
'
+test_expect_success 'create branch with prefix' '
+ git config branch.autosetupmerge false &&
+ git branch branch-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ test_must_fail git branch branch-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git branch branch-with-prefix &&
+ git checkout branch-with-prefix &&
+ git branch branch-with-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_done
base-commit: 852829b3dd2fe4e7c7fc4d8badde644cf1b66c74
--
gitgitgadget
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] branch: add 'branch.addCurrentBranchAsPrefix' config param
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
2 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2026-02-20 15:59 UTC (permalink / raw)
To: Yoann Valeri via GitGitGadget; +Cc: git, Patrick Steinhardt, Yoann Valeri
"Yoann Valeri via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: VALERI Yoann <yoann.valeri@cea.fr>
>
> This patch adds a new configuration parameter for the branch creation
> feature: 'branch.addCurrentBranchAsPrefix'. When set to true, if one
We generally do not add a configuration variable before the concept
proves useful by being available as a command line option for some
time. Have we had a command line option that corresponds to this
feature for a year or two? Such a command line option will be
necessary even after we decide to add a configuration variable to
allow users to override the configured value per-invocation basis,
e.g., "git branch --no-current-branch-prefix maint-2.54 v2.54.0",
when you want to use the feature for most of your branches but want
to deviate from that convention in selected cases.
Thanks.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] branch: add 'branch.addCurrentBranchAsPrefix' config param
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
2 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2026-02-20 16:08 UTC (permalink / raw)
To: Yoann Valeri via GitGitGadget; +Cc: git, Patrick Steinhardt, Yoann Valeri
By the way, the address at @cea.fr used as the author ident and for
sign-off seems to be bouncing, due to "550 mailbox unavailable".
Two requests:
* To the author of the patch. Could you make sure to sign-off with
reachable e-mail address? It cannot be helped that years after a
patch is written, the author may become unreachable, but we do
not want to see it happen even before we accept the patch.
* To GitGitGadget maintainers. Could you think about ways to catch
an incident like this, perhaps by sending a ping e-mail to first
time contributors to request response before allowing /submit or
something?
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 0/2] branch: add 'branch.addCurrentBranchAsPrefix' config param
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 ` Yoann Valeri via GitGitGadget
2026-02-27 15:48 ` [PATCH v2 1/2] " VALERI Yoann via GitGitGadget
` (2 more replies)
2 siblings, 3 replies; 18+ messages in thread
From: Yoann Valeri via GitGitGadget @ 2026-02-27 15:48 UTC (permalink / raw)
To: git; +Cc: Patrick Steinhardt, Junio C Hamano, Yoann Valeri, Yoann Valeri
Changes since v1:
* Added a '--no-prefix' option to git branch
VALERI Yoann (2):
branch: add 'branch.addCurrentBranchAsPrefix' config param
branch: add a no-prefix option
Documentation/config/branch.adoc | 7 +++++
branch.c | 14 +++++++++
branch.h | 8 +++++
builtin/branch.c | 24 ++++++++++-----
builtin/checkout.c | 52 +++++++++++++++++++++++---------
t/t2018-checkout-branch.sh | 26 ++++++++++++++++
t/t2060-switch.sh | 26 ++++++++++++++++
t/t3200-branch.sh | 16 ++++++++++
8 files changed, 150 insertions(+), 23 deletions(-)
base-commit: 7b2bccb0d58d4f24705bf985de1f4612e4cf06e5
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2202%2Fvaleriyoann%2Fbranch-with-prefix-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2202/valeriyoann/branch-with-prefix-v2
Pull-Request: https://github.com/git/git/pull/2202
Range-diff vs v1:
1: 30a6d8e195 = 1: 49641fb34c branch: add 'branch.addCurrentBranchAsPrefix' config param
-: ---------- > 2: 0fbdf031cb branch: add a no-prefix option
--
gitgitgadget
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 1/2] branch: add 'branch.addCurrentBranchAsPrefix' config param
2026-02-27 15:48 ` [PATCH v2 0/2] " Yoann Valeri via GitGitGadget
@ 2026-02-27 15:48 ` VALERI Yoann via GitGitGadget
2026-02-27 15:48 ` [PATCH v2 2/2] branch: add a no-prefix option VALERI Yoann via GitGitGadget
2026-03-06 13:14 ` [PATCH v3 0/3] branch: add prefixes to new branch names Yoann Valeri via GitGitGadget
2 siblings, 0 replies; 18+ messages in thread
From: VALERI Yoann via GitGitGadget @ 2026-02-27 15:48 UTC (permalink / raw)
To: git
Cc: Patrick Steinhardt, Junio C Hamano, Yoann Valeri, Yoann Valeri,
VALERI Yoann
From: VALERI Yoann <yoann.valeri@cea.fr>
This patch adds a new configuration parameter for the branch creation
feature: 'branch.addCurrentBranchAsPrefix'. When set to true, if one
creates a new branch with either `git branch`, `git checkout -[bB]` or
`git switch -[cC]`, we will now retrieve the current branch's name, and
use it as prefix for the name of the newly created branch, alongside a
hyphen separating the two.
For instance, using this parameter, and attempting to create a branch
'test' while on the 'main' branch will instead create a branch
'main-test'.
This parameters is useful for projects handling many branches, with
features often needing backport on different branches, so as to reduce
the time taken to create branches without having to come up with clever
names.
Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
---
Documentation/config/branch.adoc | 7 +++++
branch.c | 14 +++++++++
branch.h | 8 +++++
builtin/branch.c | 17 ++++++-----
builtin/checkout.c | 52 +++++++++++++++++++++++---------
t/t2018-checkout-branch.sh | 26 ++++++++++++++++
t/t2060-switch.sh | 26 ++++++++++++++++
t/t3200-branch.sh | 14 +++++++++
8 files changed, 142 insertions(+), 22 deletions(-)
diff --git a/Documentation/config/branch.adoc b/Documentation/config/branch.adoc
index a4db9fa5c8..bd153ea406 100644
--- a/Documentation/config/branch.adoc
+++ b/Documentation/config/branch.adoc
@@ -35,6 +35,13 @@ This option defaults to `never`.
value of this variable will be used as the default.
See linkgit:git-for-each-ref[1] field names for valid values.
+`branch.addCurrentBranchAsPrefix`::
+ When a new branch is created with `git branch`, `git switch` or `git
+ checkout` use the name of the current branch as a prefix for the new
+ branch's name, alongside the one provided by the user, with a hyphen in the
+ middle. For instance, using this configuration variable, creating the branch
+ `test` while on `main` will create the branch `main-test`. False by default.
+
`branch.<name>.remote`::
When on branch _<name>_, it tells `git fetch` and `git push`
which remote to fetch from or push to. The remote to push to
diff --git a/branch.c b/branch.c
index 243db7d0fc..f2d348b046 100644
--- a/branch.c
+++ b/branch.c
@@ -365,6 +365,20 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
return 0;
}
+void add_branch_prefix(const char *current_branch,
+ const char *target_branch, struct strbuf *buf)
+{
+ int value = 0;
+
+ repo_config_get_bool(the_repository,
+ "branch.addCurrentBranchAsPrefix", &value);
+
+ if (value)
+ strbuf_addf(buf, "%s-%s", current_branch, target_branch);
+ else
+ strbuf_addstr(buf, target_branch);
+}
+
/*
* Check if 'name' can be a valid name for a branch; die otherwise.
* Return 1 if the named branch already exists; return 0 otherwise.
diff --git a/branch.h b/branch.h
index ec2f35fda4..060de1b72c 100644
--- a/branch.h
+++ b/branch.h
@@ -148,6 +148,14 @@ int install_branch_config(int flag, const char *local, const char *origin, const
*/
int read_branch_desc(struct strbuf *, const char *branch_name);
+/*
+ * Fetch the configuration parameter 'branch.addCurrentBranchAsPrefix' and
+ * fill the buffer 'buf' with '<current_branch>-<target_branch>' if true,
+ * otherwise just '<current_branch>'.
+ */
+void add_branch_prefix(const char *current_branch,
+ const char *target_branch, struct strbuf *buf);
+
/*
* Check if a branch is checked out in the main worktree or any linked
* worktree and die (with a message describing its checkout location) if
diff --git a/builtin/branch.c b/builtin/branch.c
index c577b5d20f..2fbf2d9722 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -995,6 +995,7 @@ int cmd_branch(int argc,
} else if (!noncreate_actions && argc > 0 && argc <= 2) {
const char *branch_name = argv[0];
const char *start_name = argc == 2 ? argv[1] : head;
+ struct strbuf new_branch_name = STRBUF_INIT;
if (filter.kind != FILTER_REFS_BRANCHES)
die(_("the -a, and -r, options to 'git branch' do not take a branch name.\n"
@@ -1003,15 +1004,17 @@ 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"));
- if (recurse_submodules) {
- create_branches_recursively(the_repository, branch_name,
+ add_branch_prefix(start_name, branch_name, &new_branch_name);
+
+ if (recurse_submodules)
+ create_branches_recursively(the_repository, new_branch_name.buf,
start_name, NULL, force,
reflog, quiet, track, 0);
- ret = 0;
- goto out;
- }
- create_branch(the_repository, branch_name, start_name, force, 0,
- reflog, quiet, track, 0);
+ else
+ create_branch(the_repository, new_branch_name.buf, start_name,
+ force, 0, reflog, quiet, track, 0);
+
+ strbuf_release(&new_branch_name);
} else
usage_with_options(builtin_branch_usage, options);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index f7b313816e..9dc1d00ed2 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1170,31 +1170,42 @@ static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne
release_revisions(&revs);
}
+static void get_current_branch_info(struct branch_info *branch_info)
+{
+ struct object_id rev;
+ int flag;
+
+ branch_info->path = refs_resolve_refdup(get_main_ref_store(the_repository),
+ "HEAD", 0, &rev, &flag);
+
+ if (branch_info->path)
+ branch_info->commit = lookup_commit_reference_gently(the_repository,
+ &rev, 1);
+
+ if (!(flag & REF_ISSYMREF))
+ FREE_AND_NULL(branch_info->path);
+
+ if (branch_info->path) {
+ const char *const prefix = "refs/heads/";
+ const char *p;
+
+ if (skip_prefix(branch_info->path, prefix, &p))
+ branch_info->name = xstrdup(p);
+ }
+}
+
static int switch_branches(const struct checkout_opts *opts,
struct branch_info *new_branch_info)
{
int ret = 0;
struct branch_info old_branch_info = { 0 };
- struct object_id rev;
- int flag, writeout_error = 0;
+ int writeout_error = 0;
int do_merge = 1;
trace2_cmd_mode("branch");
memset(&old_branch_info, 0, sizeof(old_branch_info));
- old_branch_info.path = refs_resolve_refdup(get_main_ref_store(the_repository),
- "HEAD", 0, &rev, &flag);
- if (old_branch_info.path)
- old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
- if (!(flag & REF_ISSYMREF))
- FREE_AND_NULL(old_branch_info.path);
-
- if (old_branch_info.path) {
- const char *const prefix = "refs/heads/";
- const char *p;
- if (skip_prefix(old_branch_info.path, prefix, &p))
- old_branch_info.name = xstrdup(p);
- }
+ get_current_branch_info(&old_branch_info);
if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {
if (new_branch_info->name)
@@ -1772,6 +1783,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
int parseopt_flags = 0;
struct branch_info new_branch_info = { 0 };
int ret;
+ struct strbuf full_branch_name = { 0 };
opts->overwrite_ignore = 1;
opts->prefix = prefix;
@@ -1962,7 +1974,15 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
}
if (opts->new_branch) {
+ struct branch_info current_branch = { 0 };
struct strbuf buf = STRBUF_INIT;
+ strbuf_init(&full_branch_name, 0);
+
+ get_current_branch_info(¤t_branch);
+ add_branch_prefix(current_branch.name, opts->new_branch,
+ &full_branch_name);
+ branch_info_release(¤t_branch);
+ opts->new_branch = full_branch_name.buf;
if (opts->new_branch_force)
opts->branch_exists = validate_branchname(opts->new_branch, &buf);
@@ -1981,6 +2001,8 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
clear_pathspec(&opts->pathspec);
free(opts->pathspec_from_file);
free(options);
+ if (full_branch_name.buf)
+ strbuf_release(&full_branch_name);
return ret;
}
diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh
index a48ebdbf4d..8345a509dc 100755
--- a/t/t2018-checkout-branch.sh
+++ b/t/t2018-checkout-branch.sh
@@ -285,4 +285,30 @@ test_expect_success 'checkout -b rejects an extra path argument' '
test_grep "Cannot update paths and switch to branch" err
'
+test_expect_success 'checkout -b with prefix is valid' '
+ git checkout -b main &&
+ git checkout -b checkoutb-with-prefix &&
+ git checkout main &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ test_must_fail git checkout -b checkoutb-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git checkout -b checkoutb-with-prefix &&
+ git checkout -b checkoutb-with-prefix &&
+ test_ref_exists refs/heads/checkoutb-with-prefix &&
+ test_ref_exists refs/heads/main-checkoutb-with-prefix &&
+ test_ref_exists refs/heads/main-checkoutb-with-prefix-checkoutb-with-prefix
+'
+
+test_expect_success 'checkout -B with prefix is valid' '
+ git checkout main &&
+ git checkout -B checkoutB-with-prefix &&
+ git checkout main &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ git checkout -B checkoutB-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git checkout -B checkoutB-with-prefix &&
+ test_ref_exists refs/heads/checkoutB-with-prefix &&
+ test_ref_exists refs/heads/checkoutB-with-prefix-checkoutB-with-prefix
+'
+
test_done
diff --git a/t/t2060-switch.sh b/t/t2060-switch.sh
index c91c4db936..458f8b9f3f 100755
--- a/t/t2060-switch.sh
+++ b/t/t2060-switch.sh
@@ -177,4 +177,30 @@ test_expect_success 'switch back when temporarily detached and checked out elsew
git -C wt2 switch --ignore-other-worktrees shared
'
+test_expect_success 'switch -c with prefix is valid' '
+ git switch main &&
+ git switch -c switchc-with-prefix &&
+ git checkout main &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ test_must_fail git switch -c switchc-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git switch -c switchc-with-prefix &&
+ git switch -c switchc-with-prefix &&
+ test_ref_exists refs/heads/switchc-with-prefix &&
+ test_ref_exists refs/heads/main-switchc-with-prefix &&
+ test_ref_exists refs/heads/main-switchc-with-prefix-switchc-with-prefix
+'
+
+test_expect_success 'switch -C with prefix is valid' '
+ git switch main &&
+ git switch -C switchC-with-prefix &&
+ git checkout main &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ git switch -C switchC-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git switch -C switchC-with-prefix &&
+ test_ref_exists refs/heads/switchC-with-prefix &&
+ test_ref_exists refs/heads/switchC-with-prefix-switchC-with-prefix
+'
+
test_done
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index c58e505c43..496b034d0b 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1716,4 +1716,18 @@ test_expect_success 'errors if given a bad branch name' '
test_cmp expect actual
'
+test_expect_success 'create branch with prefix' '
+ git config branch.autosetupmerge false &&
+ git branch branch-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix false &&
+ test_must_fail git branch branch-with-prefix &&
+ test_config branch.addCurrentBranchAsPrefix true &&
+ git branch branch-with-prefix &&
+ git checkout branch-with-prefix &&
+ git branch branch-with-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_done
--
gitgitgadget
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 2/2] branch: add a no-prefix option
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
2026-02-27 17:07 ` Junio C Hamano
2026-03-06 13:14 ` [PATCH v3 0/3] branch: add prefixes to new branch names Yoann Valeri via GitGitGadget
2 siblings, 1 reply; 18+ messages in thread
From: VALERI Yoann via GitGitGadget @ 2026-02-27 15:48 UTC (permalink / raw)
To: git
Cc: Patrick Steinhardt, Junio C Hamano, Yoann Valeri, Yoann Valeri,
VALERI Yoann
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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/2] branch: add a no-prefix option
2026-02-27 15:48 ` [PATCH v2 2/2] branch: add a no-prefix option VALERI Yoann via GitGitGadget
@ 2026-02-27 17:07 ` Junio C Hamano
0 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2026-02-27 17:07 UTC (permalink / raw)
To: VALERI Yoann via GitGitGadget; +Cc: git, Patrick Steinhardt, Yoann Valeri
"VALERI Yoann via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 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>
> ---
That is unusual in multiple ways.
The usual way to do so is to give a command line option that is
usable without needing any configuration. This happens first in
early patches in a series.
And then, assuming that the command line option is widely supported
as useful (but cumbersome to specify every time), help the users by
adding a configuration variable, that can be overridden via the
command line option. That happens next in later patches in a
series.
And in order to help users discover these two features more easily,
it is customery to give them very similar names. In other words,
adding "--[no-]prefix-current-branch-name" may be more
understandable if it is added in patch [1/2], if we want to make the
matching configuration "branch.addCurrentBranchAsPrefix" in patch
[2/2].
Even better, have you considered leaving the door open for _others_
to come up with better ideas _later_ by making it extensible, e.g.,
--no-name-prefix
--name-prefix=<token>
where the initial implementation the only supported <token> is
"current" (to signal "current branch name")? That would mean that
the corresponding configuration variable would also be a string, not
a boolean, e.g., "branch.namePrefix = current".
Perhaps those who work with more than one remotes want to give their
branches meant to be pushed to remote A with prefix A- while naming
the branches meant to be pushed to remote B with prefix B-, or
something, that is not based on the current branch but something
else (e.g., @{push} in this hypothetical example). I am not saying
that you should add such a support to the feature in this series
(quite honestly, I am not convinced at all if prefixing with the
current branch name is even something worth adding myself), but we
do not want to end up with millions of branch.add${Foo}AsPrefix with
different values of ${Foo} when we discover that such prefixing
scheme is useful in the future.
Thanks.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 0/3] branch: add prefixes to new branch names
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 ` [PATCH v2 2/2] branch: add a no-prefix option VALERI Yoann via GitGitGadget
@ 2026-03-06 13:14 ` Yoann Valeri via GitGitGadget
2026-03-06 13:14 ` [PATCH v3 1/3] branch: add '--name-prefix' option VALERI Yoann via GitGitGadget
` (4 more replies)
2 siblings, 5 replies; 18+ messages in thread
From: Yoann Valeri via GitGitGadget @ 2026-03-06 13:14 UTC (permalink / raw)
To: git; +Cc: Patrick Steinhardt, Junio C Hamano, Yoann Valeri, Yoann Valeri
This PR adds a way to add prefixes to a new branch being created. The goal
is mostly to ease the developer process of creating new branches by adding
shortcuts that can be set either with a command-line option or with
configuration parameter. This is useful especially when you have to do
similar backports on multiple branches, removing a bit of the need for
finding names or typing the names over and over again.
Changes since v1:
* Added a '--no-prefix' option to git branch
Changes since v2:
* Changed the PR structure, with 3 patches:
* first patch adds the '--name-prefix' option
* second adds the 'branch.namePrefix' configuration parameter
* third adds the '--no-name-prefix' option
* Those patches only target 'git branch' now
VALERI Yoann (3):
branch: add '--name-prefix' option
branch: add 'branch.namePrefix' config param
branch: add '--no-name-prefix' option
Documentation/config/branch.adoc | 5 +++++
Documentation/git-branch.adoc | 11 ++++++++++-
branch.c | 21 ++++++++++++++++++++
branch.h | 12 +++++++++++
builtin/branch.c | 25 +++++++++++++++--------
t/t3200-branch.sh | 34 ++++++++++++++++++++++++++++++++
6 files changed, 99 insertions(+), 9 deletions(-)
base-commit: 2cc71917514657b93014134350864f4849edfc83
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2202%2Fvaleriyoann%2Fbranch-with-prefix-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2202/valeriyoann/branch-with-prefix-v3
Pull-Request: https://github.com/git/git/pull/2202
Range-diff vs v2:
1: 49641fb34c ! 1: 6cbb950d8b branch: add 'branch.addCurrentBranchAsPrefix' config param
@@ Metadata
Author: VALERI Yoann <yoann.valeri@cea.fr>
## Commit message ##
- branch: add 'branch.addCurrentBranchAsPrefix' config param
+ branch: add '--name-prefix' option
- This patch adds a new configuration parameter for the branch creation
- feature: 'branch.addCurrentBranchAsPrefix'. When set to true, if one
- creates a new branch with either `git branch`, `git checkout -[bB]` or
- `git switch -[cC]`, we will now retrieve the current branch's name, and
- use it as prefix for the name of the newly created branch, alongside a
- hyphen separating the two.
-
- For instance, using this parameter, and attempting to create a branch
- 'test' while on the 'main' branch will instead create a branch
- 'main-test'.
-
- This parameters is useful for projects handling many branches, with
- features often needing backport on different branches, so as to reduce
- the time taken to create branches without having to come up with clever
- names.
+ This patch adds a '--name-prefix' option to add a prefix to a newly
+ created branch. It can use a regular string or a token as prefix. The
+ only token currently handled is '@{current}', which is substituted for
+ the current branch's name.
Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
- ## Documentation/config/branch.adoc ##
-@@ Documentation/config/branch.adoc: This option defaults to `never`.
- value of this variable will be used as the default.
- See linkgit:git-for-each-ref[1] field names for valid values.
-
-+`branch.addCurrentBranchAsPrefix`::
-+ When a new branch is created with `git branch`, `git switch` or `git
-+ checkout` use the name of the current branch as a prefix for the new
-+ branch's name, alongside the one provided by the user, with a hyphen in the
-+ middle. For instance, using this configuration variable, creating the branch
-+ `test` while on `main` will create the branch `main-test`. False by default.
-+
- `branch.<name>.remote`::
- When on branch _<name>_, it tells `git fetch` and `git push`
- which remote to fetch from or push to. The remote to push to
+ ## Documentation/git-branch.adoc ##
+@@ Documentation/git-branch.adoc: git branch [--color[=<when>] | --no-color] [--show-current]
+ [(-r|--remotes) | (-a|--all)]
+ [--list] [<pattern>...]
+ git branch [--track[=(direct|inherit)] | --no-track] [-f]
+- [--recurse-submodules] <branch-name> [<start-point>]
++ [--recurse-submodules] [--name-prefix=<token>]
++ <branch-name> [<start-point>]
+ git branch (--set-upstream-to=<upstream>|-u <upstream>) [<branch-name>]
+ git branch --unset-upstream [<branch-name>]
+ git branch (-m|-M) [<old-branch>] <new-branch>
+@@ Documentation/git-branch.adoc: Note that this will create the new branch, but it will not switch the
+ working tree to it; use `git switch <new-branch>` to switch to the
+ new branch.
+
++With a `--name-prefix` option, you can add a prefix to the branch to create.
++This can either a simple name, or a token. Currently, only '@{current}' is
++managed as token, and will use the current branch name as prefix.
++
+ When a local branch is started off a remote-tracking branch, Git sets up the
+ branch (specifically the `branch.<name>.remote` and `branch.<name>.merge`
+ configuration entries) so that `git pull` will appropriately merge from
+@@ Documentation/git-branch.adoc: superproject's "origin/main", but tracks the submodule's "origin/main".
+ and the object it points at. _<format>_ is the same as
+ that of linkgit:git-for-each-ref[1].
+
++`--name-prefix <token>`::
++ A string that will be used as prefix to the name of the new branch to
++ create. Can be '@{current}' to use the current branch's name.
++
+ _<branch-name>_::
+ The name of the branch to create or delete.
+ The new branch name must pass all checks defined by
## branch.c ##
@@ branch.c: int read_branch_desc(struct strbuf *buf, const char *branch_name)
return 0;
}
-+void add_branch_prefix(const char *current_branch,
-+ const char *target_branch, struct strbuf *buf)
++void add_branch_prefix(const char *name_prefix,
++ const char *current_branch, struct strbuf *buf)
+{
+ int value = 0;
+
-+ repo_config_get_bool(the_repository,
-+ "branch.addCurrentBranchAsPrefix", &value);
++ if (!name_prefix)
++ return;
+
-+ if (value)
-+ strbuf_addf(buf, "%s-%s", current_branch, target_branch);
-+ else
-+ strbuf_addstr(buf, target_branch);
++ if (name_prefix[0] != '@') {
++ strbuf_addstr(buf, name_prefix);
++ return;
++ }
++
++ if (strcmp(name_prefix, "@{current}") == 0)
++ strbuf_addstr(buf, current_branch);
+}
+
/*
@@ branch.h: int install_branch_config(int flag, const char *local, const char *ori
int read_branch_desc(struct strbuf *, const char *branch_name);
+/*
-+ * Fetch the configuration parameter 'branch.addCurrentBranchAsPrefix' and
-+ * fill the buffer 'buf' with '<current_branch>-<target_branch>' if true,
-+ * otherwise just '<current_branch>'.
++ * Store in 'buf' a prefix to the name of a branch to create by using the given
++ * string 'name_prefix'. It can either be a simple string to a shorthand
++ * starting with '@'.
++ *
++ * Currently, only '@{current}' is managed, and will use 'current_branch' as
++ * prefix.
+ */
-+void add_branch_prefix(const char *current_branch,
-+ const char *target_branch, struct strbuf *buf);
++void add_branch_prefix(const char *name_prefix, const char *current_branch,
++ struct strbuf *buf);
++
+
/*
* Check if a branch is checked out in the main worktree or any linked
* worktree and die (with a message describing its checkout location) if
## builtin/branch.c ##
+@@ builtin/branch.c: int cmd_branch(int argc,
+ struct string_list sorting_options = STRING_LIST_INIT_DUP;
+ struct ref_format format = REF_FORMAT_INIT;
+ int ret;
++ const char *name_prefix = NULL;
+
+ struct option options[] = {
+ OPT_GROUP(N_("Generic options")),
+@@ builtin/branch.c: 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_STRING(0, "name-prefix", &name_prefix, N_("name"), N_("prefix for the branch to create")),
+ OPT_END(),
+ };
+
@@ builtin/branch.c: int cmd_branch(int argc,
} else if (!noncreate_actions && argc > 0 && argc <= 2) {
const char *branch_name = argv[0];
@@ builtin/branch.c: int cmd_branch(int argc,
- if (recurse_submodules) {
- create_branches_recursively(the_repository, branch_name,
-+ add_branch_prefix(start_name, branch_name, &new_branch_name);
++ add_branch_prefix(name_prefix, start_name, &new_branch_name);
++ strbuf_addstr(&new_branch_name, branch_name);
+
+ if (recurse_submodules)
+ create_branches_recursively(the_repository, new_branch_name.buf,
@@ builtin/branch.c: int cmd_branch(int argc,
usage_with_options(builtin_branch_usage, options);
- ## builtin/checkout.c ##
-@@ builtin/checkout.c: static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne
- release_revisions(&revs);
- }
-
-+static void get_current_branch_info(struct branch_info *branch_info)
-+{
-+ struct object_id rev;
-+ int flag;
-+
-+ branch_info->path = refs_resolve_refdup(get_main_ref_store(the_repository),
-+ "HEAD", 0, &rev, &flag);
-+
-+ if (branch_info->path)
-+ branch_info->commit = lookup_commit_reference_gently(the_repository,
-+ &rev, 1);
-+
-+ if (!(flag & REF_ISSYMREF))
-+ FREE_AND_NULL(branch_info->path);
-+
-+ if (branch_info->path) {
-+ const char *const prefix = "refs/heads/";
-+ const char *p;
-+
-+ if (skip_prefix(branch_info->path, prefix, &p))
-+ branch_info->name = xstrdup(p);
-+ }
-+}
-+
- static int switch_branches(const struct checkout_opts *opts,
- struct branch_info *new_branch_info)
- {
- int ret = 0;
- struct branch_info old_branch_info = { 0 };
-- struct object_id rev;
-- int flag, writeout_error = 0;
-+ int writeout_error = 0;
- int do_merge = 1;
-
- trace2_cmd_mode("branch");
-
- memset(&old_branch_info, 0, sizeof(old_branch_info));
-- old_branch_info.path = refs_resolve_refdup(get_main_ref_store(the_repository),
-- "HEAD", 0, &rev, &flag);
-- if (old_branch_info.path)
-- old_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);
-- if (!(flag & REF_ISSYMREF))
-- FREE_AND_NULL(old_branch_info.path);
--
-- if (old_branch_info.path) {
-- const char *const prefix = "refs/heads/";
-- const char *p;
-- if (skip_prefix(old_branch_info.path, prefix, &p))
-- old_branch_info.name = xstrdup(p);
-- }
-+ get_current_branch_info(&old_branch_info);
-
- if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {
- if (new_branch_info->name)
-@@ builtin/checkout.c: static int checkout_main(int argc, const char **argv, const char *prefix,
- int parseopt_flags = 0;
- struct branch_info new_branch_info = { 0 };
- int ret;
-+ struct strbuf full_branch_name = { 0 };
-
- opts->overwrite_ignore = 1;
- opts->prefix = prefix;
-@@ builtin/checkout.c: static int checkout_main(int argc, const char **argv, const char *prefix,
- }
-
- if (opts->new_branch) {
-+ struct branch_info current_branch = { 0 };
- struct strbuf buf = STRBUF_INIT;
-+ strbuf_init(&full_branch_name, 0);
-+
-+ get_current_branch_info(¤t_branch);
-+ add_branch_prefix(current_branch.name, opts->new_branch,
-+ &full_branch_name);
-+ branch_info_release(¤t_branch);
-+ opts->new_branch = full_branch_name.buf;
-
- if (opts->new_branch_force)
- opts->branch_exists = validate_branchname(opts->new_branch, &buf);
-@@ builtin/checkout.c: static int checkout_main(int argc, const char **argv, const char *prefix,
- clear_pathspec(&opts->pathspec);
- free(opts->pathspec_from_file);
- free(options);
-+ if (full_branch_name.buf)
-+ strbuf_release(&full_branch_name);
-
- return ret;
- }
-
- ## t/t2018-checkout-branch.sh ##
-@@ t/t2018-checkout-branch.sh: test_expect_success 'checkout -b rejects an extra path argument' '
- test_grep "Cannot update paths and switch to branch" err
- '
-
-+test_expect_success 'checkout -b with prefix is valid' '
-+ git checkout -b main &&
-+ git checkout -b checkoutb-with-prefix &&
-+ git checkout main &&
-+ test_config branch.addCurrentBranchAsPrefix false &&
-+ test_must_fail git checkout -b checkoutb-with-prefix &&
-+ test_config branch.addCurrentBranchAsPrefix true &&
-+ git checkout -b checkoutb-with-prefix &&
-+ git checkout -b checkoutb-with-prefix &&
-+ test_ref_exists refs/heads/checkoutb-with-prefix &&
-+ test_ref_exists refs/heads/main-checkoutb-with-prefix &&
-+ test_ref_exists refs/heads/main-checkoutb-with-prefix-checkoutb-with-prefix
-+'
-+
-+test_expect_success 'checkout -B with prefix is valid' '
-+ git checkout main &&
-+ git checkout -B checkoutB-with-prefix &&
-+ git checkout main &&
-+ test_config branch.addCurrentBranchAsPrefix false &&
-+ git checkout -B checkoutB-with-prefix &&
-+ test_config branch.addCurrentBranchAsPrefix true &&
-+ git checkout -B checkoutB-with-prefix &&
-+ test_ref_exists refs/heads/checkoutB-with-prefix &&
-+ test_ref_exists refs/heads/checkoutB-with-prefix-checkoutB-with-prefix
-+'
-+
- test_done
-
- ## t/t2060-switch.sh ##
-@@ t/t2060-switch.sh: test_expect_success 'switch back when temporarily detached and checked out elsew
- git -C wt2 switch --ignore-other-worktrees shared
- '
-
-+test_expect_success 'switch -c with prefix is valid' '
-+ git switch main &&
-+ git switch -c switchc-with-prefix &&
-+ git checkout main &&
-+ test_config branch.addCurrentBranchAsPrefix false &&
-+ test_must_fail git switch -c switchc-with-prefix &&
-+ test_config branch.addCurrentBranchAsPrefix true &&
-+ git switch -c switchc-with-prefix &&
-+ git switch -c switchc-with-prefix &&
-+ test_ref_exists refs/heads/switchc-with-prefix &&
-+ test_ref_exists refs/heads/main-switchc-with-prefix &&
-+ test_ref_exists refs/heads/main-switchc-with-prefix-switchc-with-prefix
-+'
-+
-+test_expect_success 'switch -C with prefix is valid' '
-+ git switch main &&
-+ git switch -C switchC-with-prefix &&
-+ git checkout main &&
-+ test_config branch.addCurrentBranchAsPrefix false &&
-+ git switch -C switchC-with-prefix &&
-+ test_config branch.addCurrentBranchAsPrefix true &&
-+ git switch -C switchC-with-prefix &&
-+ test_ref_exists refs/heads/switchC-with-prefix &&
-+ test_ref_exists refs/heads/switchC-with-prefix-switchC-with-prefix
-+'
-+
- test_done
-
## t/t3200-branch.sh ##
@@ t/t3200-branch.sh: test_expect_success 'errors if given a bad branch name' '
test_cmp expect actual
'
-+test_expect_success 'create branch with prefix' '
++test_expect_success 'create branch with --name-prefix' '
+ git config branch.autosetupmerge false &&
+ git branch branch-with-prefix &&
-+ test_config branch.addCurrentBranchAsPrefix false &&
-+ test_must_fail git branch branch-with-prefix &&
-+ test_config branch.addCurrentBranchAsPrefix true &&
-+ git branch branch-with-prefix &&
-+ git checkout branch-with-prefix &&
-+ git branch branch-with-prefix &&
++ git branch --name-prefix "blob" -- -with-prefix &&
++ test_must_fail git branch --name-prefix "blob" -- -with-prefix &&
++ git branch --name-prefix "@{current}" -- -with-prefix &&
++ git switch blob-with-prefix &&
++ git branch --name-prefix "@{current}" -- -with-prefix &&
++ test_must_fail git branch --name-prefix "@{current}" -- -with-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/main-with-prefix &&
++ test_ref_exists refs/heads/blob-with-prefix &&
++ test_ref_exists refs/heads/blob-with-prefix-with-prefix &&
++ git checkout main &&
++ git branch -D branch-with-prefix main-with-prefix blob-with-prefix &&
++ git branch -D blob-with-prefix-with-prefix
+'
+
test_done
-: ---------- > 2: d51f71708c branch: add 'branch.namePrefix' config param
2: 0fbdf031cb ! 3: 8f45374007 branch: add a no-prefix option
@@ Metadata
Author: VALERI Yoann <yoann.valeri@cea.fr>
## Commit message ##
- branch: add a no-prefix option
+ branch: add '--no-name-prefix' option
- This patch adds a '--no-prefix' option to 'git branch' to selectively
- override the 'branch.addCurrentBranchAsPrefix' configuration parameter.
+ This patch adds the '--no-name-prefix' option to prevent adding any
+ prefix to the branch being created, whether through the '--name-prefix'
+ option or the 'branch.namePrefix' configuration parameter.
Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
## builtin/branch.c ##
@@ builtin/branch.c: int cmd_branch(int argc,
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;
++ no_name_prefix = 0;
const char *new_upstream = NULL;
int noncreate_actions = 0;
/* possible options */
@@ builtin/branch.c: 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_STRING(0, "name-prefix", &name_prefix, N_("name"), N_("prefix for the branch to create")),
++ OPT_STRING_F(0, "name-prefix", &name_prefix, N_("name"), N_("prefix for the branch to create"), PARSE_OPT_NONEG),
++ OPT_BOOL(0, "no-name-prefix", &no_name_prefix, N_("do not use any prefix for the branch to create")),
OPT_END(),
};
@@ builtin/branch.c: 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);
+- add_branch_prefix(name_prefix, start_name, &new_branch_name);
++ if (!no_name_prefix)
++ add_branch_prefix(name_prefix, start_name, &new_branch_name);
+ strbuf_addstr(&new_branch_name, branch_name);
if (recurse_submodules)
- create_branches_recursively(the_repository, new_branch_name.buf,
## t/t3200-branch.sh ##
-@@ t/t3200-branch.sh: 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 &&
+@@ t/t3200-branch.sh: test_expect_success 'create branch with --name-prefix' '
+ git switch blob-with-prefix &&
+ git branch --name-prefix "@{current}" -- -with-prefix &&
+ test_must_fail git branch --name-prefix "@{current}" -- -with-prefix &&
++ git branch --name-prefix "blob" --no-name-prefix branch-with-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_ref_exists refs/heads/main-with-prefix &&
+ test_ref_exists refs/heads/blob-with-prefix &&
+ test_ref_exists refs/heads/blob-with-prefix-with-prefix &&
++ test_ref_exists refs/heads/branch-with-no-prefix &&
+ git checkout main &&
+ git branch -D branch-with-prefix main-with-prefix blob-with-prefix &&
+- git branch -D blob-with-prefix-with-prefix
++ git branch -D blob-with-prefix-with-prefix branch-with-no-prefix
+ '
+
+ test_expect_success 'create branch with config prefix' '
+@@ t/t3200-branch.sh: test_expect_success 'create branch with config prefix' '
+ test_config branch.namePrefix "@{current}" &&
+ git checkout main &&
+ git branch -- -with-prefix &&
++ git branch --no-name-prefix branch-with-no-prefix &&
+ test_ref_exists refs/heads/blob-with-prefix &&
+ test_ref_exists refs/heads/main-with-prefix &&
+- git branch -D blob-with-prefix main-with-prefix
++ test_ref_exists refs/heads/branch-with-no-prefix &&
++ git branch -D blob-with-prefix main-with-prefix branch-with-no-prefix
'
test_done
--
gitgitgadget
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 1/3] branch: add '--name-prefix' option
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 ` 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
` (3 subsequent siblings)
4 siblings, 2 replies; 18+ messages in thread
From: VALERI Yoann via GitGitGadget @ 2026-03-06 13:14 UTC (permalink / raw)
To: git
Cc: Patrick Steinhardt, Junio C Hamano, Yoann Valeri, Yoann Valeri,
VALERI Yoann
From: VALERI Yoann <yoann.valeri@cea.fr>
This patch adds a '--name-prefix' option to add a prefix to a newly
created branch. It can use a regular string or a token as prefix. The
only token currently handled is '@{current}', which is substituted for
the current branch's name.
Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
---
Documentation/git-branch.adoc | 11 ++++++++++-
branch.c | 17 +++++++++++++++++
branch.h | 12 ++++++++++++
builtin/branch.c | 20 +++++++++++++-------
t/t3200-branch.sh | 18 ++++++++++++++++++
5 files changed, 70 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-branch.adoc b/Documentation/git-branch.adoc
index c0afddc424..00967fa758 100644
--- a/Documentation/git-branch.adoc
+++ b/Documentation/git-branch.adoc
@@ -17,7 +17,8 @@ git branch [--color[=<when>] | --no-color] [--show-current]
[(-r|--remotes) | (-a|--all)]
[--list] [<pattern>...]
git branch [--track[=(direct|inherit)] | --no-track] [-f]
- [--recurse-submodules] <branch-name> [<start-point>]
+ [--recurse-submodules] [--name-prefix=<token>]
+ <branch-name> [<start-point>]
git branch (--set-upstream-to=<upstream>|-u <upstream>) [<branch-name>]
git branch --unset-upstream [<branch-name>]
git branch (-m|-M) [<old-branch>] <new-branch>
@@ -64,6 +65,10 @@ Note that this will create the new branch, but it will not switch the
working tree to it; use `git switch <new-branch>` to switch to the
new branch.
+With a `--name-prefix` option, you can add a prefix to the branch to create.
+This can either a simple name, or a token. Currently, only '@{current}' is
+managed as token, and will use the current branch name as prefix.
+
When a local branch is started off a remote-tracking branch, Git sets up the
branch (specifically the `branch.<name>.remote` and `branch.<name>.merge`
configuration entries) so that `git pull` will appropriately merge from
@@ -319,6 +324,10 @@ superproject's "origin/main", but tracks the submodule's "origin/main".
and the object it points at. _<format>_ is the same as
that of linkgit:git-for-each-ref[1].
+`--name-prefix <token>`::
+ A string that will be used as prefix to the name of the new branch to
+ create. Can be '@{current}' to use the current branch's name.
+
_<branch-name>_::
The name of the branch to create or delete.
The new branch name must pass all checks defined by
diff --git a/branch.c b/branch.c
index 243db7d0fc..c24d7ce823 100644
--- a/branch.c
+++ b/branch.c
@@ -365,6 +365,23 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
return 0;
}
+void add_branch_prefix(const char *name_prefix,
+ const char *current_branch, struct strbuf *buf)
+{
+ int value = 0;
+
+ if (!name_prefix)
+ return;
+
+ if (name_prefix[0] != '@') {
+ strbuf_addstr(buf, name_prefix);
+ return;
+ }
+
+ if (strcmp(name_prefix, "@{current}") == 0)
+ strbuf_addstr(buf, current_branch);
+}
+
/*
* Check if 'name' can be a valid name for a branch; die otherwise.
* Return 1 if the named branch already exists; return 0 otherwise.
diff --git a/branch.h b/branch.h
index ec2f35fda4..f4ac1e9bbd 100644
--- a/branch.h
+++ b/branch.h
@@ -148,6 +148,18 @@ int install_branch_config(int flag, const char *local, const char *origin, const
*/
int read_branch_desc(struct strbuf *, const char *branch_name);
+/*
+ * Store in 'buf' a prefix to the name of a branch to create by using the given
+ * string 'name_prefix'. It can either be a simple string to a shorthand
+ * starting with '@'.
+ *
+ * Currently, only '@{current}' is managed, and will use 'current_branch' as
+ * prefix.
+ */
+void add_branch_prefix(const char *name_prefix, const char *current_branch,
+ struct strbuf *buf);
+
+
/*
* Check if a branch is checked out in the main worktree or any linked
* worktree and die (with a message describing its checkout location) if
diff --git a/builtin/branch.c b/builtin/branch.c
index c577b5d20f..58631913c7 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -725,6 +725,7 @@ int cmd_branch(int argc,
struct string_list sorting_options = STRING_LIST_INIT_DUP;
struct ref_format format = REF_FORMAT_INIT;
int ret;
+ const char *name_prefix = NULL;
struct option options[] = {
OPT_GROUP(N_("Generic 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_STRING(0, "name-prefix", &name_prefix, N_("name"), N_("prefix for the branch to create")),
OPT_END(),
};
@@ -995,6 +997,7 @@ int cmd_branch(int argc,
} else if (!noncreate_actions && argc > 0 && argc <= 2) {
const char *branch_name = argv[0];
const char *start_name = argc == 2 ? argv[1] : head;
+ struct strbuf new_branch_name = STRBUF_INIT;
if (filter.kind != FILTER_REFS_BRANCHES)
die(_("the -a, and -r, options to 'git branch' do not take a branch name.\n"
@@ -1003,15 +1006,18 @@ 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"));
- if (recurse_submodules) {
- create_branches_recursively(the_repository, branch_name,
+ add_branch_prefix(name_prefix, start_name, &new_branch_name);
+ strbuf_addstr(&new_branch_name, branch_name);
+
+ if (recurse_submodules)
+ create_branches_recursively(the_repository, new_branch_name.buf,
start_name, NULL, force,
reflog, quiet, track, 0);
- ret = 0;
- goto out;
- }
- create_branch(the_repository, branch_name, start_name, force, 0,
- reflog, quiet, track, 0);
+ else
+ create_branch(the_repository, new_branch_name.buf, start_name,
+ force, 0, reflog, quiet, track, 0);
+
+ strbuf_release(&new_branch_name);
} else
usage_with_options(builtin_branch_usage, options);
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index c58e505c43..550989a2bb 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1716,4 +1716,22 @@ test_expect_success 'errors if given a bad branch name' '
test_cmp expect actual
'
+test_expect_success 'create branch with --name-prefix' '
+ git config branch.autosetupmerge false &&
+ git branch branch-with-prefix &&
+ git branch --name-prefix "blob" -- -with-prefix &&
+ test_must_fail git branch --name-prefix "blob" -- -with-prefix &&
+ git branch --name-prefix "@{current}" -- -with-prefix &&
+ git switch blob-with-prefix &&
+ git branch --name-prefix "@{current}" -- -with-prefix &&
+ test_must_fail git branch --name-prefix "@{current}" -- -with-prefix &&
+ test_ref_exists refs/heads/branch-with-prefix &&
+ test_ref_exists refs/heads/main-with-prefix &&
+ test_ref_exists refs/heads/blob-with-prefix &&
+ test_ref_exists refs/heads/blob-with-prefix-with-prefix &&
+ git checkout main &&
+ git branch -D branch-with-prefix main-with-prefix blob-with-prefix &&
+ git branch -D blob-with-prefix-with-prefix
+'
+
test_done
--
gitgitgadget
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 2/3] branch: add 'branch.namePrefix' config param
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-06 13:14 ` 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
` (2 subsequent siblings)
4 siblings, 1 reply; 18+ messages in thread
From: VALERI Yoann via GitGitGadget @ 2026-03-06 13:14 UTC (permalink / raw)
To: git
Cc: Patrick Steinhardt, Junio C Hamano, Yoann Valeri, Yoann Valeri,
VALERI Yoann
From: VALERI Yoann <yoann.valeri@cea.fr>
This patch adds a new configuration parameter for the branch creation
feature: 'branch.namePrefix'. It corresponds to the '--name-prefix'
option of 'git branch' made as configuration parameter, and behaves
exactly like it.
Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
---
Documentation/config/branch.adoc | 5 +++++
branch.c | 18 +++++++++++-------
t/t3200-branch.sh | 12 ++++++++++++
3 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/Documentation/config/branch.adoc b/Documentation/config/branch.adoc
index a4db9fa5c8..202c9048b4 100644
--- a/Documentation/config/branch.adoc
+++ b/Documentation/config/branch.adoc
@@ -35,6 +35,11 @@ This option defaults to `never`.
value of this variable will be used as the default.
See linkgit:git-for-each-ref[1] field names for valid values.
+`branch.namePrefix`::
+ When a new branch is created with `git branch`, use the provided value as
+ prefix for its name. Can be '@{current}' to use the current branch's name
+ as prefix.
+
`branch.<name>.remote`::
When on branch _<name>_, it tells `git fetch` and `git push`
which remote to fetch from or push to. The remote to push to
diff --git a/branch.c b/branch.c
index c24d7ce823..5fb7280d47 100644
--- a/branch.c
+++ b/branch.c
@@ -368,18 +368,22 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
void add_branch_prefix(const char *name_prefix,
const char *current_branch, struct strbuf *buf)
{
- int value = 0;
+ char *config_prefix = NULL;
- if (!name_prefix)
- return;
+ if (!name_prefix) {
+ if (repo_config_get_string(the_repository, "branch.namePrefix",
+ &config_prefix))
+ return;
- if (name_prefix[0] != '@') {
- strbuf_addstr(buf, name_prefix);
- return;
+ name_prefix = config_prefix;
}
- if (strcmp(name_prefix, "@{current}") == 0)
+ if (name_prefix[0] != '@')
+ strbuf_addstr(buf, name_prefix);
+ else if (strcmp(name_prefix, "@{current}") == 0)
strbuf_addstr(buf, current_branch);
+
+ free(config_prefix);
}
/*
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 550989a2bb..847a8355cf 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1734,4 +1734,16 @@ test_expect_success 'create branch with --name-prefix' '
git branch -D blob-with-prefix-with-prefix
'
+test_expect_success 'create branch with config prefix' '
+ test_config branch.namePrefix blob &&
+ git branch -- -with-prefix &&
+ test_must_fail git branch -- -with-prefix &&
+ test_config branch.namePrefix "@{current}" &&
+ git checkout main &&
+ git branch -- -with-prefix &&
+ test_ref_exists refs/heads/blob-with-prefix &&
+ test_ref_exists refs/heads/main-with-prefix &&
+ git branch -D blob-with-prefix main-with-prefix
+'
+
test_done
--
gitgitgadget
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 3/3] branch: add '--no-name-prefix' option
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-06 13:14 ` [PATCH v3 2/3] branch: add 'branch.namePrefix' config param VALERI Yoann via GitGitGadget
@ 2026-03-06 13:14 ` 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
4 siblings, 1 reply; 18+ messages in thread
From: VALERI Yoann via GitGitGadget @ 2026-03-06 13:14 UTC (permalink / raw)
To: git
Cc: Patrick Steinhardt, Junio C Hamano, Yoann Valeri, Yoann Valeri,
VALERI Yoann
From: VALERI Yoann <yoann.valeri@cea.fr>
This patch adds the '--no-name-prefix' option to prevent adding any
prefix to the branch being created, whether through the '--name-prefix'
option or the 'branch.namePrefix' configuration parameter.
Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
---
builtin/branch.c | 9 ++++++---
t/t3200-branch.sh | 8 ++++++--
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 58631913c7..204d7865d1 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_name_prefix = 0;
const char *new_upstream = NULL;
int noncreate_actions = 0;
/* possible options */
@@ -777,7 +778,8 @@ 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_STRING(0, "name-prefix", &name_prefix, N_("name"), N_("prefix for the branch to create")),
+ OPT_STRING_F(0, "name-prefix", &name_prefix, N_("name"), N_("prefix for the branch to create"), PARSE_OPT_NONEG),
+ OPT_BOOL(0, "no-name-prefix", &no_name_prefix, N_("do not use any prefix for the branch to create")),
OPT_END(),
};
@@ -1006,7 +1008,8 @@ 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(name_prefix, start_name, &new_branch_name);
+ if (!no_name_prefix)
+ add_branch_prefix(name_prefix, start_name, &new_branch_name);
strbuf_addstr(&new_branch_name, branch_name);
if (recurse_submodules)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 847a8355cf..cbaa45330f 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1725,13 +1725,15 @@ test_expect_success 'create branch with --name-prefix' '
git switch blob-with-prefix &&
git branch --name-prefix "@{current}" -- -with-prefix &&
test_must_fail git branch --name-prefix "@{current}" -- -with-prefix &&
+ git branch --name-prefix "blob" --no-name-prefix branch-with-no-prefix &&
test_ref_exists refs/heads/branch-with-prefix &&
test_ref_exists refs/heads/main-with-prefix &&
test_ref_exists refs/heads/blob-with-prefix &&
test_ref_exists refs/heads/blob-with-prefix-with-prefix &&
+ test_ref_exists refs/heads/branch-with-no-prefix &&
git checkout main &&
git branch -D branch-with-prefix main-with-prefix blob-with-prefix &&
- git branch -D blob-with-prefix-with-prefix
+ git branch -D blob-with-prefix-with-prefix branch-with-no-prefix
'
test_expect_success 'create branch with config prefix' '
@@ -1741,9 +1743,11 @@ test_expect_success 'create branch with config prefix' '
test_config branch.namePrefix "@{current}" &&
git checkout main &&
git branch -- -with-prefix &&
+ git branch --no-name-prefix branch-with-no-prefix &&
test_ref_exists refs/heads/blob-with-prefix &&
test_ref_exists refs/heads/main-with-prefix &&
- git branch -D blob-with-prefix main-with-prefix
+ test_ref_exists refs/heads/branch-with-no-prefix &&
+ git branch -D blob-with-prefix main-with-prefix branch-with-no-prefix
'
test_done
--
gitgitgadget
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v3 0/3] branch: add prefixes to new branch names
2026-03-06 13:14 ` [PATCH v3 0/3] branch: add prefixes to new branch names Yoann Valeri via GitGitGadget
` (2 preceding siblings ...)
2026-03-06 13:14 ` [PATCH v3 3/3] branch: add '--no-name-prefix' option VALERI Yoann via GitGitGadget
@ 2026-03-06 21:01 ` Junio C Hamano
2026-03-07 7:05 ` Eric Sunshine
4 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2026-03-06 21:01 UTC (permalink / raw)
To: Yoann Valeri via GitGitGadget; +Cc: git, Patrick Steinhardt, Yoann Valeri
"Yoann Valeri via GitGitGadget" <gitgitgadget@gmail.com> writes:
> This PR adds a way to add prefixes to a new branch being created. The goal
> is mostly to ease the developer process of creating new branches by adding
> shortcuts that can be set either with a command-line option or with
> configuration parameter. This is useful especially when you have to do
> similar backports on multiple branches, removing a bit of the need for
> finding names or typing the names over and over again.
>
> Changes since v1:
>
> * Added a '--no-prefix' option to git branch
>
> Changes since v2:
>
> * Changed the PR structure, with 3 patches:
> * first patch adds the '--name-prefix' option
> * second adds the 'branch.namePrefix' configuration parameter
> * third adds the '--no-name-prefix' option
> * Those patches only target 'git branch' now
I haven't read the actual patches, but the first step that adds
"--name-prefix" should also support "--no-name-prefix" at the same
time, with or without patches 2 and 3. Doing so would allow users
with an alias
[alias] bn = branch --name-prefix=blah
, who want to almost always add "blah" to their branches, to defeat
the prefix in rare occasions with
$ git bn --no-name-prefix foo
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 3/3] branch: add '--no-name-prefix' option
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
0 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2026-03-06 21:38 UTC (permalink / raw)
To: VALERI Yoann via GitGitGadget; +Cc: git, Patrick Steinhardt, Yoann Valeri
"VALERI Yoann via GitGitGadget" <gitgitgadget@gmail.com> writes:
> - OPT_STRING(0, "name-prefix", &name_prefix, N_("name"), N_("prefix for the branch to create")),
> + OPT_STRING_F(0, "name-prefix", &name_prefix, N_("name"), N_("prefix for the branch to create"), PARSE_OPT_NONEG),
> + OPT_BOOL(0, "no-name-prefix", &no_name_prefix, N_("do not use any prefix for the branch to create")),
You do not want a separate "no-*" entry in the options[] table.
If we look at parse-options.c to see how OPTION_STRING is handled,
we find:
case OPTION_STRING:
if (unset)
*(const char **)opt->value = NULL;
else if (opt->flags & PARSE_OPT_OPTARG && !p->opt)
*(const char **)opt->value = (const char *)opt->defval;
else
return get_arg(p, opt, flags, (const char **)opt->value);
return 0;
which tells us
* "--no-name-prefix" is caught by "if (unset)" and causes the
name_prefix variable set to NULL.
* if we give OPT_OPTARG, we can allow "--name-prefix" (with no
parameter) to default to opt->defval value; this feature is not
very useful in our application.
* Otherwise we get the string after "--name-prefix=".
So you do not need to do anything strange. To correctly implement
the order of handling configuration and command line, you would do:
* initialize name_prefix to NULL. By default no name_prefix is
used.
* early in the cmd_branch() before you call parse_options(),
consult the configuration and pick up branch.nameprefix
and set it to name_prefix variable.
* then you call parse_options(). If the command line has
"--no-name-prefix", "if (unset)" kicks in and clears the
name_prefix variable pointed at by the opt->value. If the
command line has "--name-prefix=blah", the name_prefix variable,
which may have obtained a value from the configuration, is
overwritten with "blah". If the command line does not do
anything, then the name_prefix variable will retain whatever
value it got from the configuration.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 0/3] branch: add prefixes to new branch names
2026-03-06 13:14 ` [PATCH v3 0/3] branch: add prefixes to new branch names Yoann Valeri via GitGitGadget
` (3 preceding siblings ...)
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
4 siblings, 1 reply; 18+ messages in thread
From: Eric Sunshine @ 2026-03-07 7:05 UTC (permalink / raw)
To: Yoann Valeri via GitGitGadget
Cc: git, Patrick Steinhardt, Junio C Hamano, Yoann Valeri
On Fri, Mar 6, 2026 at 8:14 AM Yoann Valeri via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> This PR adds a way to add prefixes to a new branch being created. The goal
> is mostly to ease the developer process of creating new branches by adding
> shortcuts that can be set either with a command-line option or with
> configuration parameter. This is useful especially when you have to do
> similar backports on multiple branches, removing a bit of the need for
> finding names or typing the names over and over again.
Sorry, but I'm having trouble understanding the value of this patch
series. Neither the cover letter nor the patches themselves provide
enough context to really understand how this feature would be helpful.
Adding some real-world examples of how this simplifies your workflow
*might* help sell the idea. Without such examples, it's difficult to
imagine that you can't achieve the same with some simple aliases or
tooling/scripting on your side.
My other concern is that this implementation is too special-case by
assuming that users will only want to apply the "special value" as a
prefix. It is easy to imagine some users instead wanting the special
value added as a suffix or embedded. As such, a (possibly) more
palatable implementation (assuming this feature is even desirable at
all) might be to instead allow the user to specify some sort of format
string into which the special value (or values) is interpolated.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 1/3] branch: add '--name-prefix' option
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
1 sibling, 0 replies; 18+ messages in thread
From: Eric Sunshine @ 2026-03-07 7:06 UTC (permalink / raw)
To: VALERI Yoann via GitGitGadget
Cc: git, Patrick Steinhardt, Junio C Hamano, Yoann Valeri
On Fri, Mar 6, 2026 at 8:15 AM VALERI Yoann via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> This patch adds a '--name-prefix' option to add a prefix to a newly
> created branch. It can use a regular string or a token as prefix. The
> only token currently handled is '@{current}', which is substituted for
> the current branch's name.
>
> Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
> ---
> diff --git a/Documentation/git-branch.adoc b/Documentation/git-branch.adoc
> @@ -64,6 +65,10 @@ Note that this will create the new branch, but it will not switch the
> +With a `--name-prefix` option, you can add a prefix to the branch to create.
> +This can either a simple name, or a token. Currently, only '@{current}' is
> +managed as token, and will use the current branch name as prefix.
s/This can/& be/
> diff --git a/branch.c b/branch.c
> @@ -365,6 +365,23 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
> +void add_branch_prefix(const char *name_prefix,
> + const char *current_branch, struct strbuf *buf)
> +{
> + int value = 0;
What is `value`? It doesn't seem to be used at all in this function.
> + if (!name_prefix)
> + return;
> +
> + if (name_prefix[0] != '@') {
> + strbuf_addstr(buf, name_prefix);
> + return;
> + }
> +
> + if (strcmp(name_prefix, "@{current}") == 0)
> + strbuf_addstr(buf, current_branch);
> +}
I would expect this function to produce some sort of diagnostic
warning when the user has given it a "@{token}" it doesn't recognize.
> diff --git a/branch.h b/branch.h
> @@ -148,6 +148,18 @@ int install_branch_config(int flag, const char *local, const char *origin, const
> +/*
> + * Store in 'buf' a prefix to the name of a branch to create by using the given
> + * string 'name_prefix'. It can either be a simple string to a shorthand
> + * starting with '@'.
> + *
> + * Currently, only '@{current}' is managed, and will use 'current_branch' as
> + * prefix.
> + */
> +void add_branch_prefix(const char *name_prefix, const char *current_branch,
> + struct strbuf *buf);
It feels unnecessarily burdensome to force the caller to compute and
pass in `current_branch`. Intuitively, one would expect
add_branch_prefix() to compute the current branch itself if it
discovers that "@{current}" has been requested.
Moveover, this approach will not scale well when support for
additional "@{tokens}" is added down the road since it burdens *all*
callers with providing the values for *all* possible tokens.
> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> @@ -1716,4 +1716,22 @@ test_expect_success 'errors if given a bad branch name' '
> +test_expect_success 'create branch with --name-prefix' '
> + git config branch.autosetupmerge false &&
Let's use `test_config` which will ensure that this setting is
reverted at the end of the test.
> + git branch branch-with-prefix &&
> + git branch --name-prefix "blob" -- -with-prefix &&
> + test_must_fail git branch --name-prefix "blob" -- -with-prefix &&
> + git branch --name-prefix "@{current}" -- -with-prefix &&
> + git switch blob-with-prefix &&
> + git branch --name-prefix "@{current}" -- -with-prefix &&
> + test_must_fail git branch --name-prefix "@{current}" -- -with-prefix &&
> + test_ref_exists refs/heads/branch-with-prefix &&
> + test_ref_exists refs/heads/main-with-prefix &&
> + test_ref_exists refs/heads/blob-with-prefix &&
> + test_ref_exists refs/heads/blob-with-prefix-with-prefix &&
> + git checkout main &&
> + git branch -D branch-with-prefix main-with-prefix blob-with-prefix &&
> + git branch -D blob-with-prefix-with-prefix
> +'
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 2/3] branch: add 'branch.namePrefix' config param
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
0 siblings, 0 replies; 18+ messages in thread
From: Eric Sunshine @ 2026-03-07 7:07 UTC (permalink / raw)
To: VALERI Yoann via GitGitGadget
Cc: git, Patrick Steinhardt, Junio C Hamano, Yoann Valeri
On Fri, Mar 6, 2026 at 8:15 AM VALERI Yoann via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> This patch adds a new configuration parameter for the branch creation
> feature: 'branch.namePrefix'. It corresponds to the '--name-prefix'
> option of 'git branch' made as configuration parameter, and behaves
> exactly like it.
>
> Signed-off-by: VALERI Yoann <yoann.valeri@cea.fr>
> ---
> diff --git a/Documentation/config/branch.adoc b/Documentation/config/branch.adoc
> @@ -35,6 +35,11 @@ This option defaults to `never`.
> +`branch.namePrefix`::
> + When a new branch is created with `git branch`, use the provided value as
> + prefix for its name. Can be '@{current}' to use the current branch's name
> + as prefix.
This probably ought to mention --[no]-name-prefix to let the user know
that the configuration value can be overridden.
> diff --git a/branch.c b/branch.c
> @@ -368,18 +368,22 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
> void add_branch_prefix(const char *name_prefix,
> const char *current_branch, struct strbuf *buf)
> {
> - int value = 0;
> + char *config_prefix = NULL;
>
> - if (!name_prefix)
> - return;
> + if (!name_prefix) {
> + if (repo_config_get_string(the_repository, "branch.namePrefix",
> + &config_prefix))
> + return;
>
> - if (name_prefix[0] != '@') {
> - strbuf_addstr(buf, name_prefix);
> - return;
> + name_prefix = config_prefix;
> }
>
> - if (strcmp(name_prefix, "@{current}") == 0)
> + if (name_prefix[0] != '@')
> + strbuf_addstr(buf, name_prefix);
> + else if (strcmp(name_prefix, "@{current}") == 0)
> strbuf_addstr(buf, current_branch);
> +
> + free(config_prefix);
> }
This "diff" is very difficult to read because it's rewriting much of
the logic which was first introduced in patch [1/3]. When you reroll,
it would be a good idea to get the overall logic straight in patch
[1/3] so that subsequent patches only make small changes to it to
improve it (if necessary).
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 0/3] branch: add prefixes to new branch names
2026-03-07 7:05 ` Eric Sunshine
@ 2026-03-08 6:48 ` Junio C Hamano
0 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2026-03-08 6:48 UTC (permalink / raw)
To: Eric Sunshine
Cc: Yoann Valeri via GitGitGadget, git, Patrick Steinhardt,
Yoann Valeri
Eric Sunshine <sunshine@sunshineco.com> writes:
> Sorry, but I'm having trouble understanding the value of this patch
> series. Neither the cover letter nor the patches themselves provide
> enough context to really understand how this feature would be helpful.
> Adding some real-world examples of how this simplifies your workflow
> *might* help sell the idea. Without such examples, it's difficult to
> imagine that you can't achieve the same with some simple aliases or
> tooling/scripting on your side.
Very reasonable suggestion. Thanks.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 1/3] branch: add '--name-prefix' option
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
1 sibling, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2026-03-08 7:06 UTC (permalink / raw)
To: VALERI Yoann via GitGitGadget; +Cc: git, Patrick Steinhardt, Yoann Valeri
"VALERI Yoann via GitGitGadget" <gitgitgadget@gmail.com> writes:
> diff --git a/Documentation/git-branch.adoc b/Documentation/git-branch.adoc
> index c0afddc424..00967fa758 100644
> --- a/Documentation/git-branch.adoc
> +++ b/Documentation/git-branch.adoc
> @@ -17,7 +17,8 @@ git branch [--color[=<when>] | --no-color] [--show-current]
> [(-r|--remotes) | (-a|--all)]
> [--list] [<pattern>...]
> git branch [--track[=(direct|inherit)] | --no-track] [-f]
> - [--recurse-submodules] <branch-name> [<start-point>]
> + [--recurse-submodules] [--name-prefix=<token>]
> + <branch-name> [<start-point>]
The indentation of the last line seems a bit off; the previous line
uses leading HT both in the original and in the updated version, but
the last line uses SP indent.
> @@ -64,6 +65,10 @@ Note that this will create the new branch, but it will not switch the
> working tree to it; use `git switch <new-branch>` to switch to the
> new branch.
>
> +With a `--name-prefix` option, you can add a prefix to the branch to create.
> +This can either a simple name, or a token. Currently, only '@{current}' is
> +managed as token, and will use the current branch name as prefix.
"can either" -> "can either be".
"managed" -> "supported".
> @@ -319,6 +324,10 @@ superproject's "origin/main", but tracks the submodule's "origin/main".
> and the object it points at. _<format>_ is the same as
> that of linkgit:git-for-each-ref[1].
>
> +`--name-prefix <token>`::
> + A string that will be used as prefix to the name of the new branch to
> + create. Can be '@{current}' to use the current branch's name.
> +
> _<branch-name>_::
> The name of the branch to create or delete.
> The new branch name must pass all checks defined by
> diff --git a/branch.c b/branch.c
> index 243db7d0fc..c24d7ce823 100644
> --- a/branch.c
> +++ b/branch.c
> @@ -365,6 +365,23 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
> return 0;
> }
>
> +void add_branch_prefix(const char *name_prefix,
> + const char *current_branch, struct strbuf *buf)
Overly deep indentation here. Our tab-width is always 8, and you
would align the first "const char" on these two lines.
> +{
> + int value = 0;
Unused variable?
> + if (!name_prefix)
> + return;
> +
> + if (name_prefix[0] != '@') {
> + strbuf_addstr(buf, name_prefix);
> + return;
> + }
> +
> + if (strcmp(name_prefix, "@{current}") == 0)
> + strbuf_addstr(buf, current_branch);
> +}
What happens when we need to support more than the @{current}? Will
this function grow more parameters and the callers need to prepare
more parameters, even if only one of them may be picked by this
function? That does not smell like a sound way to make things
maintainable.
> diff --git a/builtin/branch.c b/builtin/branch.c
> index c577b5d20f..58631913c7 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> ...
> + add_branch_prefix(name_prefix, start_name, &new_branch_name);
Here, `start_name` is passed as `current_branch` to `add_branch_prefix`.
However, `start_name` is the `<start-point>` (e.g., another branch,
a tag, or a commit). If the user runs:
$ git branch --name-prefix=@{current} new-branch other-branch
the prefix will be `other-branch` instead of the *current* branch
name as advertised in the documentation. It _may_ be how the
feature was intended to work, but then the name "current" and the
way the documentation describes the token are both misleading.
> + create_branch(the_repository, new_branch_name.buf, start_name,
> + force, 0, reflog, quiet, track, 0);
Overly deep indentation.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2026-03-08 7:06 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2 2/2] branch: add a no-prefix option VALERI Yoann via GitGitGadget
2026-02-27 17:07 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox