summaryrefslogtreecommitdiff
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-02-05 20:48:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-02-05 21:49:53 (GMT)
commit59e1205d167c9acc17114a2f96425325470b1db8 (patch)
treea1f9580da38066b216c09ada5ef0cf9aa95e868b /builtin/fetch.c
parentba2aa15129e59f248d8cdd30404bc78b5178f61d (diff)
downloadgit-59e1205d167c9acc17114a2f96425325470b1db8.zip
git-59e1205d167c9acc17114a2f96425325470b1db8.tar.gz
git-59e1205d167c9acc17114a2f96425325470b1db8.tar.bz2
ls-refs: report unborn targets of symrefs
When cloning, we choose the default branch based on the remote HEAD. But if there is no remote HEAD reported (which could happen if the target of the remote HEAD is unborn), we'll fall back to using our local init.defaultBranch. Traditionally this hasn't been a big deal, because most repos used "master" as the default. But these days it is likely to cause confusion if the server and client implementations choose different values (e.g., if the remote started with "main", we may choose "master" locally, create commits there, and then the user is surprised when they push to "master" and not "main"). To solve this, the remote needs to communicate the target of the HEAD symref, even if it is unborn, and "git clone" needs to use this information. Currently, symrefs that have unborn targets (such as in this case) are not communicated by the protocol. Teach Git to advertise and support the "unborn" feature in "ls-refs" (by default, this is advertised, but server administrators may turn this off through the lsrefs.unborn config). This feature indicates that "ls-refs" supports the "unborn" argument; when it is specified, "ls-refs" will send the HEAD symref with the name of its unborn target. This change is only for protocol v2. A similar change for protocol v0 would require independent protocol design (there being no analogous position to signal support for "unborn") and client-side plumbing of the data required, so the scope of this patch set is limited to protocol v2. The client side will be updated to use this in a subsequent commit. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
0 files changed, 0 insertions, 0 deletions