3 test_description
='test local clone'
7 find "$1/objects" -type f
-links 1 >output
&&
8 test_line_count
= 0 output
11 test_expect_success
'preparing origin repository' '
12 : >file && git add . && git commit -m1 &&
13 git clone --bare . a.git &&
14 git clone --bare . x &&
15 test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true &&
16 test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true &&
17 git bundle create b1.bundle --all &&
18 git bundle create b2.bundle master &&
20 cp b1.bundle dir/b3 &&
24 test_expect_success
'local clone without .git suffix' '
25 git clone -l -s a b &&
27 test "$(GIT_CONFIG=.git/config git config --bool core.bare)" = false &&
31 test_expect_success
'local clone with .git suffix' '
32 git clone -l -s a.git c &&
36 test_expect_success
'local clone from x' '
37 git clone -l -s x y &&
41 test_expect_success
'local clone from x.git that does not exist' '
42 test_must_fail git clone -l -s x.git z
45 test_expect_success
'With -no-hardlinks, local will make a copy' '
46 git clone --bare --no-hardlinks x w &&
47 ! repo_is_hardlinked w
50 test_expect_success
'Even without -l, local will make a hardlink' '
52 git clone -l --bare x w &&
56 test_expect_success
'local clone of repo with nonexistent ref in HEAD' '
57 echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
61 test ! -e .git/refs/remotes/origin/HEAD)
64 test_expect_success
'bundle clone without .bundle suffix' '
69 test_expect_success
'bundle clone with .bundle suffix' '
70 git clone b1.bundle &&
74 test_expect_success
'bundle clone from b4' '
79 test_expect_success
'bundle clone from b4.bundle that does not exist' '
80 test_must_fail git clone b4.bundle bb
83 test_expect_success
'bundle clone with nonexistent HEAD' '
84 git clone b2.bundle b2 &&
87 test_must_fail git rev-parse --verify refs/heads/master)
90 test_expect_success
'clone empty repository' '
94 git config receive.denyCurrentBranch warn) &&
95 git clone empty empty-clone &&
98 echo "content" >> foo &&
100 git commit -m "Initial commit" &&
101 git push origin master &&
102 expected=$(git rev-parse master) &&
103 actual=$(git --git-dir=../empty/.git rev-parse master) &&
104 test $actual = $expected)
107 test_expect_success
'clone empty repository, and then push should not segfault.' '
108 rm -fr empty/ empty-clone/ &&
110 (cd empty && git init) &&
111 git clone empty empty-clone &&
113 test_must_fail git push)
116 test_expect_success
'cloning non-existent directory fails' '
117 rm -rf does-not-exist &&
118 test_must_fail git clone does-not-exist
121 test_expect_success
'cloning non-git directory fails' '
122 rm -rf not-a-git-repo not-a-git-repo-clone &&
123 mkdir not-a-git-repo &&
124 test_must_fail git clone not-a-git-repo not-a-git-repo-clone
127 test_expect_success
'cloning file:// does not hardlink' '
128 git clone --bare file://"$(pwd)"/a non-local &&
129 ! repo_is_hardlinked non-local
132 test_expect_success
'cloning a local path with --no-local does not hardlink' '
133 git clone --bare --no-local a force-nonlocal &&
134 ! repo_is_hardlinked force-nonlocal