Re: Re* [PATCH 8/9] fast-export: respect the possibly-overridden default branch name
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 11, 2020, 18:18 UTC
- Message-ID
- <xmqqimfxjwk6.fsf@gitster.c.googlers.com>
- In-Reply-To
- <xmqqtuzha6xn.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 25 quoted lines
>> diff --git a/builtin/fast-export.c b/builtin/fast-export.c
>> index 85868162ee..a306a60d25 100644
>> --- a/builtin/fast-export.c
>> +++ b/builtin/fast-export.c
>> @@ -497,7 +497,7 @@ static void *anonymize_ref_component(const void *old, size_t *len)
>> {
>> static int counter;
>> struct strbuf out = STRBUF_INIT;
>> - strbuf_addf(&out, "ref%d", counter++);
>> + strbuf_addf(&out, "ref%d", ++counter);
>> return strbuf_detach(&out, len);
>> }
>>
>> @@ -522,7 +522,7 @@ static const char *anonymize_refname(const char *refname)
>> * anything interesting.
>> */
>> if (!strcmp(refname, "refs/heads/master"))
>> - return refname;
>> + return "ref0";
>
> This is obviously wrong. It should return "refs/heads/ref0".
> ...
> So, I guess we should just fix the patch I am responding to to
> return "refs/heads/ref0" instead of "ref0", and queue it as one of
> the preparatory steps.... and the follow-up step to become part of the series you are working on to allow customing what the primary branch is called would turn the second hunk to
- if (!strcmp(refname, "refs/heads/master")) + if (!strcmp(refname, get_primary_branch_name(0))) return "refs/heads/ref0";
By the way, with your "two variables" approach to make both the "default" (for 'init' and 'clone') and the "primary" (for 'fmt-merge-msg' and 'fast-export') configurable, we'd need accessor function(s) for the primary branch name for the given repository. The get_primary_branch_name() helper function might want to take a "struct repository *" argument in addition to "please give me an abbreviated refname" boolean, given the recent push to pass the struct to everybody.