Re: Re* [PATCH 8/9] fast-export: respect the possibly-overridden default branch name
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 13, 2020, 16:25 UTC
- Message-ID
- <xmqqv9jvylt7.fsf@gitster.c.googlers.com>
- In-Reply-To
- <405521ec-aed7-ff76-5b48-70e9d11018e6@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
Show 22 quoted lines
> Am 12.06.20 um 17:14 schrieb Junio C Hamano: >> /* >> * Anonymize the name used for the primary branch in this >> * repository, but reserve `ref0` for it, so that it can >> * be identified among other refs in the output. >> */ >> >> is the minimum I would expect before calling it an improvement. We >> could add >> >> It is often `main` for new repositories (and `master` for >> aged ones) and such well-known names may not need >> anonymizing, but it could be configured to use a secret word >> that the user may not want to reveal. >> >> at the end to explain the motivation behind anonymizing even more, >> if we wanted to. > > IMO, making the primary branch identifiable is a reasonable > justification to treat it specially. But then, why does it have to be > renamed to 'ref0'? Couldn't it just be renamed to Git's default primary > branch name, be it 'master' today or 'main' or whatever in the future?
That comes from https://lore.kernel.org/git/xmqqtuzha6xn.fsf@gitster.c.googlers.com/
But I agree with you 100% if you literally mean 'master' (or 'main') hardcoded without any end-user customization. What I rejected and replaced with the vanilla "ref0" was to return the configured name that will be used for the primary branch in new repositories. The above proposal suggested a faulty:
- if (!strcmp(refname, "refs/heads/master")) - return refname; + if (!strcmp(refname, get_primary_branch_name(DO_NOT_ABBREV))) + return get_default_branch_name(DO_NOT_ABBREV);
A corrected code should return a hardwired constant 'main' (it probably gets behind a C preprocessor macro, but the point is that we do not want end-user customization) for the reason stated in that message.
Thanks.