]>
Commit | Line | Data |
---|---|---|
defe13a2 AR |
1 | #!/bin/sh |
2 | ||
3 | test_description='test local clone' | |
4 | . ./test-lib.sh | |
5 | ||
6 | D=`pwd` | |
7 | ||
8 | test_expect_success 'preparing origin repository' ' | |
9 | : >file && git add . && git commit -m1 && | |
10 | git clone --bare . a.git && | |
312efe9b JH |
11 | git clone --bare . x && |
12 | test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true && | |
2dec68cf | 13 | test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true && |
b2a6d1c6 | 14 | git bundle create b1.bundle --all && |
f0298cf1 | 15 | git bundle create b2.bundle master && |
c6fef0bb | 16 | mkdir dir && |
2dec68cf | 17 | cp b1.bundle dir/b3 && |
c6fef0bb | 18 | cp b1.bundle b4 |
defe13a2 AR |
19 | ' |
20 | ||
21 | test_expect_success 'local clone without .git suffix' ' | |
22 | cd "$D" && | |
23 | git clone -l -s a b && | |
24 | cd b && | |
312efe9b | 25 | test "$(GIT_CONFIG=.git/config git config --bool core.bare)" = false && |
defe13a2 AR |
26 | git fetch |
27 | ' | |
28 | ||
29 | test_expect_success 'local clone with .git suffix' ' | |
30 | cd "$D" && | |
31 | git clone -l -s a.git c && | |
32 | cd c && | |
33 | git fetch | |
34 | ' | |
35 | ||
36 | test_expect_success 'local clone from x' ' | |
37 | cd "$D" && | |
38 | git clone -l -s x y && | |
39 | cd y && | |
40 | git fetch | |
41 | ' | |
42 | ||
43 | test_expect_success 'local clone from x.git that does not exist' ' | |
44 | cd "$D" && | |
45 | if git clone -l -s x.git z | |
46 | then | |
47 | echo "Oops, should have failed" | |
48 | false | |
49 | else | |
50 | echo happy | |
51 | fi | |
52 | ' | |
53 | ||
3d5c418f JH |
54 | test_expect_success 'With -no-hardlinks, local will make a copy' ' |
55 | cd "$D" && | |
56 | git clone --bare --no-hardlinks x w && | |
57 | cd w && | |
58 | linked=$(find objects -type f ! -links 1 | wc -l) && | |
70f64148 | 59 | test 0 = $linked |
3d5c418f JH |
60 | ' |
61 | ||
62 | test_expect_success 'Even without -l, local will make a hardlink' ' | |
63 | cd "$D" && | |
64 | rm -fr w && | |
65 | git clone -l --bare x w && | |
66 | cd w && | |
67 | copied=$(find objects -type f -links 1 | wc -l) && | |
70f64148 | 68 | test 0 = $copied |
3d5c418f JH |
69 | ' |
70 | ||
5274ba69 GP |
71 | test_expect_success 'local clone of repo with nonexistent ref in HEAD' ' |
72 | cd "$D" && | |
73 | echo "ref: refs/heads/nonexistent" > a.git/HEAD && | |
74 | git clone a d && | |
75 | cd d && | |
76 | git fetch && | |
77 | test ! -e .git/refs/remotes/origin/HEAD' | |
78 | ||
c6fef0bb SB |
79 | test_expect_success 'bundle clone without .bundle suffix' ' |
80 | cd "$D" && | |
81 | git clone dir/b3 && | |
82 | cd b3 && | |
83 | git fetch | |
84 | ' | |
85 | ||
86 | test_expect_success 'bundle clone with .bundle suffix' ' | |
87 | cd "$D" && | |
88 | git clone b1.bundle && | |
89 | cd b1 && | |
90 | git fetch | |
91 | ' | |
92 | ||
93 | test_expect_success 'bundle clone from b4' ' | |
94 | cd "$D" && | |
95 | git clone b4 bdl && | |
96 | cd bdl && | |
97 | git fetch | |
98 | ' | |
99 | ||
100 | test_expect_success 'bundle clone from b4.bundle that does not exist' ' | |
101 | cd "$D" && | |
102 | if git clone b4.bundle bb | |
103 | then | |
104 | echo "Oops, should have failed" | |
105 | false | |
106 | else | |
107 | echo happy | |
108 | fi | |
109 | ' | |
110 | ||
111 | test_expect_success 'bundle clone with nonexistent HEAD' ' | |
112 | cd "$D" && | |
113 | git clone b2.bundle b2 && | |
114 | cd b2 && | |
2dec68cf | 115 | git fetch && |
c6fef0bb SB |
116 | test ! -e .git/refs/heads/master |
117 | ' | |
118 | ||
86ac7518 SR |
119 | test_expect_success 'clone empty repository' ' |
120 | cd "$D" && | |
121 | mkdir empty && | |
acd2a45b JH |
122 | (cd empty && |
123 | git init && | |
124 | git config receive.denyCurrentBranch warn) && | |
86ac7518 SR |
125 | git clone empty empty-clone && |
126 | test_tick && | |
127 | (cd empty-clone | |
128 | echo "content" >> foo && | |
129 | git add foo && | |
130 | git commit -m "Initial commit" && | |
131 | git push origin master && | |
132 | expected=$(git rev-parse master) && | |
133 | actual=$(git --git-dir=../empty/.git rev-parse master) && | |
134 | test $actual = $expected) | |
135 | ' | |
136 | ||
a162e78d MM |
137 | test_expect_success 'clone empty repository, and then push should not segfault.' ' |
138 | cd "$D" && | |
139 | rm -fr empty/ empty-clone/ && | |
140 | mkdir empty && | |
141 | (cd empty && git init) && | |
142 | git clone empty empty-clone && | |
b9d622e7 JS |
143 | (cd empty-clone && |
144 | test_must_fail git push) | |
a162e78d MM |
145 | ' |
146 | ||
a9026187 JK |
147 | test_expect_success 'cloning non-existent directory fails' ' |
148 | cd "$D" && | |
149 | rm -rf does-not-exist && | |
150 | test_must_fail git clone does-not-exist | |
151 | ' | |
152 | ||
153 | test_expect_success 'cloning non-git directory fails' ' | |
154 | cd "$D" && | |
155 | rm -rf not-a-git-repo not-a-git-repo-clone && | |
156 | mkdir not-a-git-repo && | |
157 | test_must_fail git clone not-a-git-repo not-a-git-repo-clone | |
158 | ' | |
159 | ||
defe13a2 | 160 | test_done |