Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2020-06-24 17:46:35 +0300
committerJunio C Hamano <gitster@pobox.com>2020-06-24 19:14:21 +0300
commita471214bd610bb415a37d5b2c3506b83549acd57 (patch)
treeda4811bd343763fb77d4166a9802e6fdb39bf4ba /t/t5606-clone-options.sh
parent0cc1b475bbcc530c5429c741fbcfdc2730d27223 (diff)
remote: use the configured default branch name when appropriate
When guessing the default branch name of a remote, and there are no refs to guess from, we want to go with the preference specified by the user for the fall-back, i.e. the default name to be used for the initial branch of new repositories (because as far as the user is concerned, a remote that has no branches yet is a new repository). At the same time, when talking to an older Git server that does not report a symref for `HEAD` (but instead reports a commit hash), let's try to guess the configured default branch name first. If it does not match the reported commit hash, let's fall back to `master` as before. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5606-clone-options.sh')
-rwxr-xr-xt/t5606-clone-options.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh
index 286bfd93ac..e69427f881 100755
--- a/t/t5606-clone-options.sh
+++ b/t/t5606-clone-options.sh
@@ -47,7 +47,16 @@ test_expect_success 'guesses initial branch name correctly' '
test_commit -C initial-branch no-spoilers &&
git -C initial-branch branch abc guess &&
git clone initial-branch is-it &&
- test refs/heads/guess = $(git -C is-it symbolic-ref HEAD)
+ test refs/heads/guess = $(git -C is-it symbolic-ref HEAD) &&
+
+ git -c init.defaultBranch=none init --bare no-head &&
+ git -C initial-branch push ../no-head guess abc &&
+ git clone no-head is-it2 &&
+ test_must_fail git -C is-it2 symbolic-ref refs/remotes/origin/HEAD &&
+ git -C no-head update-ref --no-deref HEAD refs/heads/guess &&
+ git -c init.defaultBranch=guess clone no-head is-it3 &&
+ test refs/remotes/origin/guess = \
+ $(git -C is-it3 symbolic-ref refs/remotes/origin/HEAD)
'
test_done