]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5702-protocol-v2.sh
clone: use remote branch if it matches default HEAD
[thirdparty/git.git] / t / t5702-protocol-v2.sh
index 2b3a78b842f30e2764ed88c1f885009a2de22a90..5d42a355a8b81b0f2087eeb8302eb7859c04553c 100755 (executable)
@@ -288,6 +288,27 @@ test_expect_success 'bare clone propagates unborn HEAD from non-empty repo' '
        ! grep "warning:" stderr
 '
 
+test_expect_success 'defaulted HEAD uses remote branch if available' '
+       test_when_finished "rm -rf file_unborn_parent file_unborn_child" &&
+
+       git init file_unborn_parent &&
+       (
+               cd file_unborn_parent &&
+               git config lsrefs.unborn ignore &&
+               git checkout -b branchwithstuff &&
+               test_commit --no-tag stuff &&
+               git symbolic-ref HEAD refs/heads/mydefaultbranch
+       ) &&
+
+       GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
+       git -c init.defaultBranch=branchwithstuff -c protocol.version=2 \
+               clone "file://$(pwd)/file_unborn_parent" \
+               file_unborn_child 2>stderr &&
+       grep "refs/heads/branchwithstuff" file_unborn_child/.git/HEAD &&
+       test_path_is_file file_unborn_child/stuff.t &&
+       ! grep "warning:" stderr
+'
+
 test_expect_success 'fetch with file:// using protocol v2' '
        test_when_finished "rm -f log" &&