Revision 6b58df54cf0f461abb35bb2fac407d2547dbc2f0 authored by Jeff King on 20 September 2021, 19:04:10 UTC, committed by Junio C Hamano on 20 September 2021, 21:05:36 UTC
When cloning a repository with an unborn HEAD, we'll set the local HEAD to match it only if the local repository is non-bare. This is inconsistent with all other combinations: remote HEAD | local repo | local HEAD ----------------------------------------------- points to commit | non-bare | same as remote points to commit | bare | same as remote unborn | non-bare | same as remote unborn | bare | local default So I don't think this is some clever or subtle behavior, but just a bug in 4f37d45706 (clone: respect remote unborn HEAD, 2021-02-05). And it's easy to see how we ended up there. Before that commit, the code to set up the HEAD for an empty repo was guarded by "if (!option_bare)". That's because the only thing it did was call install_branch_config(), and we don't want to do so for a bare repository (unborn HEAD or not). That commit put the handling of unborn HEADs into the same block, since those also need to call install_branch_config(). But the unborn case has an additional side effect of calling create_symref(), and we want that to happen whether we are bare or not. This patch just pulls all of the "figure out the default branch" code out of the "!option_bare" block. Only the actual config installation is kept there. Note that this does mean we might allocate "ref" and not use it (if the remote is empty but did not advertise an unborn HEAD). But that's not really a big deal since this isn't a hot code path, and it keeps the code simple. The alternative would be handling unborn_head_target separately, but that gets confusing since its memory ownership is tangled up with the "ref" variable. There's just one new test, for the case we're fixing. The other ones in the table are handled elsewhere (the unborn non-bare case just above, and the actually-born cases in t5601, t5606, and t5609, as they do not require v2's "unborn" protocol extension). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 225bc32
File | Mode | Size |
---|---|---|
.gitignore | -rw-r--r-- | 7 bytes |
README.md | -rw-r--r-- | 13.2 KB |
TEAMS | -rw-r--r-- | 2.7 KB |
bg.po | -rw-r--r-- | 1009.2 KB |
ca.po | -rw-r--r-- | 777.4 KB |
de.po | -rw-r--r-- | 790.0 KB |
el.po | -rw-r--r-- | 524.1 KB |
es.po | -rw-r--r-- | 765.6 KB |
fr.po | -rw-r--r-- | 790.6 KB |
git.pot | -rw-r--r-- | 501.9 KB |
id.po | -rw-r--r-- | 615.3 KB |
is.po | -rw-r--r-- | 3.3 KB |
it.po | -rw-r--r-- | 773.6 KB |
ko.po | -rw-r--r-- | 557.5 KB |
pl.po | -rw-r--r-- | 769.5 KB |
pt_PT.po | -rw-r--r-- | 710.9 KB |
ru.po | -rw-r--r-- | 785.6 KB |
sv.po | -rw-r--r-- | 816.7 KB |
tr.po | -rw-r--r-- | 776.6 KB |
vi.po | -rw-r--r-- | 903.6 KB |
zh_CN.po | -rw-r--r-- | 730.8 KB |
zh_TW.po | -rw-r--r-- | 728.9 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...