fetch: set remote/HEAD if it does not exist

When cloning a repository remote/HEAD is created, but when the user
creates a repository with git init, and later adds a remote, remote/HEAD
is only created if the user explicitly runs a variant of "remote
set-head". Attempt to set remote/HEAD during fetch, if the user does not
have it already set. Silently ignore any errors.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Bence Ferdinandy
2024-11-22 13:28:50 +01:00
committed by Junio C Hamano
parent 9963746c84
commit 3f763ddf28
12 changed files with 203 additions and 17 deletions

View File

@ -150,7 +150,8 @@ test_expect_success 'scalar clone' '
"$(pwd)" &&
git for-each-ref --format="%(refname)" refs/remotes/origin/ >actual &&
echo "refs/remotes/origin/parallel" >expect &&
echo "refs/remotes/origin/HEAD" >>expect &&
echo "refs/remotes/origin/parallel" >>expect &&
test_cmp expect actual &&
test_path_is_missing 1/2 &&
@ -219,7 +220,7 @@ test_expect_success 'scalar reconfigure --all with includeIf.onbranch' '
done
'
test_expect_success 'scalar reconfigure --all with detached HEADs' '
test_expect_success 'scalar reconfigure --all with detached HEADs' '
repos="two three four" &&
for num in $repos
do