Re: [PATCH v2 02/12] fmt-merge-msg: introduce a way to override the main branch name
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 15, 2020, 17:05 UTC
- Message-ID
- <xmqqr1ugw97e.fsf@gitster.c.googlers.com>
- In-Reply-To
- <f4d547391537e5c3b0b4a07adb41b6aa56541fc3.1592225416.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 24 quoted lines
> diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
> index 72d32bd73b1..43f4f829242 100644
> --- a/fmt-merge-msg.c
> +++ b/fmt-merge-msg.c
> @@ -407,7 +407,7 @@ static void fmt_merge_msg_title(struct strbuf *out,
> const char *current_branch)
> {
> int i = 0;
> - char *sep = "";
> + char *sep = "", *main_branch;
>
> strbuf_addstr(out, "Merge ");
> for (i = 0; i < srcs.nr; i++) {
> @@ -451,10 +451,12 @@ static void fmt_merge_msg_title(struct strbuf *out,
> strbuf_addf(out, " of %s", srcs.items[i].string);
> }
>
> - if (!strcmp("master", current_branch))
> + main_branch = git_main_branch_name();
> + if (!strcmp(main_branch, current_branch))
> strbuf_addch(out, '\n');
> else
> strbuf_addf(out, " into %s\n", current_branch);
> + free(main_branch);While you are at it, taking
https://lore.kernel.org/git/20200614211500.GA22505@dcvr/
and the response to it into consideration, I'd suggest we should support the case where the user says "no single branch is special here" by configuring it to an empty string.
> +core.mainBranch:: > + The name of the main (or: primary) branch in the current repository. > + For historical reasons, `master` is used as the fall-back for this > + setting.
As to the naming of the configuration variable and the actual fall-back value, I would strongly suggest making them DIFFERNT (i.e. separate the concept from an actual value).
An instruction
... oh, if you want to do so, you can set the core.mainBranch
configuration variable to 'main'sounds strange than
... oh, if you want to do so, you can set the core.primaryBranch
configuration variable to 'main'at least to me, and since I am OK with your choice of 'main' as the replacement for 'master', a separate word would be more appropriate for the variable name.