From: Eric Sunshine Date: Sat, 07 Mar 2026 07:07:30 GMT Subject: Re: [PATCH v3 2/3] branch: add 'branch.namePrefix' config param Message-ID: In-Reply-To: On Fri, Mar 6, 2026 at 8:15 AM VALERI Yoann via GitGitGadget 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 > --- > 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).