3 test_description
='test local clone'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 find "$1/objects" -type f
-links 1 >output
&&
11 test_line_count
= 0 output
14 test_expect_success
'preparing origin repository' '
15 : >file && git add . && git commit -m1 &&
16 git clone --bare . a.git &&
17 git clone --bare . x &&
18 test "$(cd a.git && git config --bool core.bare)" = true &&
19 test "$(cd x && git config --bool core.bare)" = true &&
20 git bundle create b1.bundle --all &&
21 git bundle create b2.bundle main &&
23 cp b1.bundle dir/b3 &&
27 test_expect_success
'local clone without .git suffix' '
28 git clone -l -s a b &&
30 test "$(git config --bool core.bare)" = false &&
34 test_expect_success
'local clone with .git suffix' '
35 git clone -l -s a.git c &&
39 test_expect_success
'local clone from x' '
40 git clone -l -s x y &&
44 test_expect_success
'local clone from x.git that does not exist' '
45 test_must_fail git clone -l -s x.git z
48 test_expect_success
'With -no-hardlinks, local will make a copy' '
49 git clone --bare --no-hardlinks x w &&
50 ! repo_is_hardlinked w
53 test_expect_success
'Even without -l, local will make a hardlink' '
55 git clone -l --bare x w &&
59 test_expect_success
'local clone of repo with nonexistent ref in HEAD' '
60 echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
64 test ! -e .git/refs/remotes/origin/HEAD)
67 test_expect_success
'bundle clone without .bundle suffix' '
72 test_expect_success
'bundle clone with .bundle suffix' '
73 git clone b1.bundle &&
77 test_expect_success
'bundle clone from b4' '
82 test_expect_success
'bundle clone from b4.bundle that does not exist' '
83 test_must_fail git clone b4.bundle bb
86 test_expect_success
'bundle clone with nonexistent HEAD' '
87 git clone b2.bundle b2 &&
90 test_must_fail git rev-parse --verify refs/heads/main)
93 test_expect_success
'clone empty repository' '
97 git config receive.denyCurrentBranch warn) &&
98 git clone empty empty-clone &&
101 echo "content" >> foo &&
103 git commit -m "Initial commit" &&
104 git push origin main &&
105 expected=$(git rev-parse main) &&
106 actual=$(git --git-dir=../empty/.git rev-parse main) &&
107 test $actual = $expected)
110 test_expect_success
'clone empty repository, and then push should not segfault.' '
111 rm -fr empty/ empty-clone/ &&
113 (cd empty && git init) &&
114 git clone empty empty-clone &&
116 test_must_fail git push)
119 test_expect_success
'cloning non-existent directory fails' '
120 rm -rf does-not-exist &&
121 test_must_fail git clone does-not-exist
124 test_expect_success
'cloning non-git directory fails' '
125 rm -rf not-a-git-repo not-a-git-repo-clone &&
126 mkdir not-a-git-repo &&
127 test_must_fail git clone not-a-git-repo not-a-git-repo-clone
130 test_expect_success
'cloning file:// does not hardlink' '
131 git clone --bare file://"$(pwd)"/a non-local &&
132 ! repo_is_hardlinked non-local
135 test_expect_success
'cloning a local path with --no-local does not hardlink' '
136 git clone --bare --no-local a force-nonlocal &&
137 ! repo_is_hardlinked force-nonlocal
140 test_expect_success
'cloning locally respects "-u" for fetching refs' '
141 test_must_fail git clone --bare -u false a should_not_work.git
144 test_expect_success
'local clone from repo with corrupt refs fails gracefully' '
146 test_commit -C corrupt one &&
147 echo a >corrupt/.git/refs/heads/topic &&
149 test_must_fail git clone corrupt working 2>err &&
150 grep "has a null OID" err