Re: [PATCH v3 2/3] branch: add 'branch.namePrefix' config param
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Mar 7, 2026, 07:07 UTC
- Message-ID
- <CAPig+cQ_jY8ofigbbtcdakaijS0XhzJFvEkOCPdZpdkt=qMTow@mail.gmail.com>
- In-Reply-To
- <d51f71708ceb0263c8e10b6d7915f7a426c88f2e.1772802872.git.gitgitgadget@gmail.com>
On Fri, Mar 6, 2026 at 8:15 AM VALERI Yoann via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 13 quoted lines
> 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.
Show 29 quoted lines
> 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).