3
3
test_description=' test local clone'
4
4
. ./test-lib.sh
5
5
6
- D=` pwd`
6
+ repo_is_hardlinked () {
7
+ find " $1 /objects" -type f -links 1 > output &&
8
+ test_line_count = 0 output
9
+ }
7
10
8
11
test_expect_success ' preparing origin repository' '
9
12
: >file && git add . && git commit -m1 &&
@@ -19,105 +22,72 @@ test_expect_success 'preparing origin repository' '
19
22
'
20
23
21
24
test_expect_success ' local clone without .git suffix' '
22
- cd "$D" &&
23
25
git clone -l -s a b &&
24
- cd b &&
26
+ ( cd b &&
25
27
test "$(GIT_CONFIG=.git/config git config --bool core.bare)" = false &&
26
- git fetch
28
+ git fetch)
27
29
'
28
30
29
31
test_expect_success ' local clone with .git suffix' '
30
- cd "$D" &&
31
32
git clone -l -s a.git c &&
32
- cd c &&
33
- git fetch
33
+ (cd c && git fetch)
34
34
'
35
35
36
36
test_expect_success ' local clone from x' '
37
- cd "$D" &&
38
37
git clone -l -s x y &&
39
- cd y &&
40
- git fetch
38
+ (cd y && git fetch)
41
39
'
42
40
43
41
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
42
+ test_must_fail git clone -l -s x.git z
52
43
'
53
44
54
45
test_expect_success ' With -no-hardlinks, local will make a copy' '
55
- cd "$D" &&
56
46
git clone --bare --no-hardlinks x w &&
57
- cd w &&
58
- linked=$(find objects -type f ! -links 1 | wc -l) &&
59
- test 0 = $linked
47
+ ! repo_is_hardlinked w
60
48
'
61
49
62
50
test_expect_success ' Even without -l, local will make a hardlink' '
63
- cd "$D" &&
64
51
rm -fr w &&
65
52
git clone -l --bare x w &&
66
- cd w &&
67
- copied=$(find objects -type f -links 1 | wc -l) &&
68
- test 0 = $copied
53
+ repo_is_hardlinked w
69
54
'
70
55
71
56
test_expect_success ' local clone of repo with nonexistent ref in HEAD' '
72
- cd "$D" &&
73
57
echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
74
58
git clone a d &&
75
- cd d &&
59
+ ( cd d &&
76
60
git fetch &&
77
- test ! -e .git/refs/remotes/origin/HEAD'
61
+ test ! -e .git/refs/remotes/origin/HEAD)
62
+ '
78
63
79
64
test_expect_success ' bundle clone without .bundle suffix' '
80
- cd "$D" &&
81
65
git clone dir/b3 &&
82
- cd b3 &&
83
- git fetch
66
+ (cd b3 && git fetch)
84
67
'
85
68
86
69
test_expect_success ' bundle clone with .bundle suffix' '
87
- cd "$D" &&
88
70
git clone b1.bundle &&
89
- cd b1 &&
90
- git fetch
71
+ (cd b1 && git fetch)
91
72
'
92
73
93
74
test_expect_success ' bundle clone from b4' '
94
- cd "$D" &&
95
75
git clone b4 bdl &&
96
- cd bdl &&
97
- git fetch
76
+ (cd bdl && git fetch)
98
77
'
99
78
100
79
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
80
+ test_must_fail git clone b4.bundle bb
109
81
'
110
82
111
83
test_expect_success ' bundle clone with nonexistent HEAD' '
112
- cd "$D" &&
113
84
git clone b2.bundle b2 &&
114
- cd b2 &&
85
+ ( cd b2 &&
115
86
git fetch &&
116
- test ! -e .git/ refs/heads/master
87
+ test_must_fail git rev-parse --verify refs/heads/master)
117
88
'
118
89
119
90
test_expect_success ' clone empty repository' '
120
- cd "$D" &&
121
91
mkdir empty &&
122
92
(cd empty &&
123
93
git init &&
@@ -135,7 +105,6 @@ test_expect_success 'clone empty repository' '
135
105
'
136
106
137
107
test_expect_success ' clone empty repository, and then push should not segfault.' '
138
- cd "$D" &&
139
108
rm -fr empty/ empty-clone/ &&
140
109
mkdir empty &&
141
110
(cd empty && git init) &&
@@ -145,13 +114,11 @@ test_expect_success 'clone empty repository, and then push should not segfault.'
145
114
'
146
115
147
116
test_expect_success ' cloning non-existent directory fails' '
148
- cd "$D" &&
149
117
rm -rf does-not-exist &&
150
118
test_must_fail git clone does-not-exist
151
119
'
152
120
153
121
test_expect_success ' cloning non-git directory fails' '
154
- cd "$D" &&
155
122
rm -rf not-a-git-repo not-a-git-repo-clone &&
156
123
mkdir not-a-git-repo &&
157
124
test_must_fail git clone not-a-git-repo not-a-git-repo-clone
0 commit comments