Re: [PATCH v2 09/12] clone: handle overridden main branch names
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jun 23, 2020, 20:58 UTC
- Message-ID
- <nycvar.QRO.7.76.6.2006232233290.54@tvgsbejvaqbjf.bet>
- In-Reply-To
- <20200616132216.GH666057@coredump.intra.peff.net>
Hi Peff,
On Tue, 16 Jun 2020, Jeff King wrote:
Show 20 quoted lines
> On Mon, Jun 15, 2020 at 12:50:13PM +0000, Johannes Schindelin via GitGitGadget wrote:
>
> > diff --git a/builtin/clone.c b/builtin/clone.c
> > index 487b0a42d75..755fcaeb0ba 100644
> > --- a/builtin/clone.c
> > +++ b/builtin/clone.c
> > @@ -718,6 +718,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
> > /* Local default branch link */
> > if (create_symref("HEAD", our->name, NULL) < 0)
> > die(_("unable to update HEAD"));
> > + git_config_set("core.mainbranch", head);
> > if (!option_bare) {
> > update_ref(msg, "HEAD", &our->old_oid, NULL, 0,
> > UPDATE_REFS_DIE_ON_ERR);
>
> Just making sure I understand what's going on here...
>
> This covers the case that we've run "clone -b foo" or similar, but there
> are two other case arms when "foo" is a tag, or the remote HEAD is
> unreachable. And there we don't set core.mainbranch at all.It was actually meant to catch the case where the remote repository has a default branch other than `master`.
Show 14 quoted lines
> But we would not want it to be missing, because that will likely need to > stay a default for "master" indefinitely (to keep behavior for existing > repositories). However, it won't be missing. We'll always have set it > during the init_db() call, and this is just overriding that. So we'd end > update_head() with either: > > - core.mainbranch set to the same branch we point HEAD to, whether we > got it from the remote side or from "-b foo" > > - if we write a detached HEAD, then core.mainbranch remains at > init.mainbranch (or defaulting to "master" now, and probably "main" > later). We have no better option. > > If so, then that makes sense to me.
In any case, this does not matter anymore, as I am dropping `core.mainBranch` from v3, as you had suggested elsewhere in this thread.
Ciao, Dscho