[PATCH 07/16] Guess the default branch based on current namespace

Richard richard.maw at gmail.com
Fri Jul 29 17:42:58 CEST 2016


On 29 July 2016 at 15:36, Jason A. Donenfeld <Jason at zx2c4.com> wrote:
> On Sat, Jul 16, 2016 at 12:59 AM, Richard Maw <richard.maw at gmail.com> wrote:
>> -
>> -       ref = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
>> -       if (!ref || !starts_with(ref, "refs/heads/"))
>> +       char *namespaced_head = NULL;
>> +
>> +       if (get_git_namespace())
>> +               namespaced_head = mkpathdup("%sHEAD", get_git_namespace());
>> +       /* NOTE: RESOLVE_REF_NO_RECURSE is required to prevent it resolving HEAD
>> +          into a ref outside of the namespace. */
>> +       ref = resolve_ref_unsafe(namespaced_head ?: "HEAD", RESOLVE_REF_NO_RECURSE, sha1, NULL);
>
> Except now, for the non-namespaced case, we don't recurse on symbolic
> entries, which might not be desirable.

I've never seen anyone use doubly indirect symbolic refs for HEAD before,
but I can't say that doesn't happen.

I'll conditionalise the flag if I can't make resolve_ref_unsafe namespace aware.

> Rather than this, would it be possible to make the underlying upstream
> function namespace aware? By the environment variable perhaps?

I'm not sure how well git would cope with resolve_ref_unsafe being
suddenly namespace aware,
so I'd probably gate it behind a flag as well.


More information about the CGit mailing list