]> git.ipfire.org Git - thirdparty/git.git/commit
clone: move unborn head creation to update_head()
authorJeff King <peff@peff.net>
Mon, 11 Jul 2022 09:21:52 +0000 (05:21 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Jul 2022 20:32:37 +0000 (13:32 -0700)
commitdaf7898abbadef81b120f455323066158514d61b
tree2b2678edf7ffcf8916b1d87798c7012335712c59
parentcc8fcd1e1ac6ae2a7463b295ccb48e18c73f924a
clone: move unborn head creation to update_head()

Prior to 4f37d45706 (clone: respect remote unborn HEAD, 2021-02-05),
creation of the local HEAD was always done in update_head(). That commit
added code to handle an unborn head in an empty repository, and just did
all symref creation and config setup there.

This makes the code flow a little bit confusing, especially as new
corner cases have been covered (like the previous commit to match our
default branch name to a non-HEAD remote branch).

Let's move the creation of the unborn symref into update_head(). This
matches the other HEAD-creation cases, and now the logic is consistently
separated: the main cmd_clone() function only examines the situation and
sets variables based on what it finds, and update_head() actually
performs the update.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clone.c