]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5702-protocol-v2.sh
Merge branch 'jt/trace2-BUG'
[thirdparty/git.git] / t / t5702-protocol-v2.sh
index e8f0b4a299ea6afade7a2fc941776c6896de0849..9113d209c5145b93c1304d17715568afe1fd0fa6 100755 (executable)
@@ -212,6 +212,31 @@ test_expect_success 'clone with file:// using protocol v2' '
        grep "ref-prefix refs/tags/" log
 '
 
+test_expect_success 'clone of empty repo propagates name of default branch' '
+       test_when_finished "rm -rf file_empty_parent file_empty_child" &&
+
+       GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
+       git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
+
+       GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
+       git -c init.defaultBranch=main -c protocol.version=2 \
+               clone "file://$(pwd)/file_empty_parent" file_empty_child &&
+       grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
+'
+
+test_expect_success '...but not if explicitly forbidden by config' '
+       test_when_finished "rm -rf file_empty_parent file_empty_child" &&
+
+       GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
+       git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
+       test_config -C file_empty_parent lsrefs.unborn ignore &&
+
+       GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
+       git -c init.defaultBranch=main -c protocol.version=2 \
+               clone "file://$(pwd)/file_empty_parent" file_empty_child &&
+       ! grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
+'
+
 test_expect_success 'fetch with file:// using protocol v2' '
        test_when_finished "rm -f log" &&