worktree: handle broken symrefs in find_shared_symref()
[git.git] / t / t5612-clone-refspec.sh
blobfac5a738519fe4aec0c3b2328c410db693c11f63
1 #!/bin/sh
3 test_description='test refspec written by clone-command'
4 . ./test-lib.sh
6 test_expect_success 'setup' '
7 # Make two branches, "master" and "side"
8 echo one >file &&
9 git add file &&
10 git commit -m one &&
11 echo two >file &&
12 git commit -a -m two &&
13 git tag two &&
14 echo three >file &&
15 git commit -a -m three &&
16 git checkout -b side &&
17 echo four >file &&
18 git commit -a -m four &&
19 git checkout master &&
20 git tag five &&
22 # default clone
23 git clone . dir_all &&
25 # default clone --no-tags
26 git clone --no-tags . dir_all_no_tags &&
28 # default --single that follows HEAD=master
29 git clone --single-branch . dir_master &&
31 # default --single that follows HEAD=master with no tags
32 git clone --single-branch --no-tags . dir_master_no_tags &&
34 # default --single that follows HEAD=side
35 git checkout side &&
36 git clone --single-branch . dir_side &&
38 # explicit --single that follows side
39 git checkout master &&
40 git clone --single-branch --branch side . dir_side2 &&
42 # default --single with --mirror
43 git clone --single-branch --mirror . dir_mirror &&
45 # default --single with --branch and --mirror
46 git clone --single-branch --mirror --branch side . dir_mirror_side &&
48 # --single that does not know what branch to follow
49 git checkout two^ &&
50 git clone --single-branch . dir_detached &&
52 # explicit --single with tag
53 git clone --single-branch --branch two . dir_tag &&
55 # explicit --single with tag and --no-tags
56 git clone --single-branch --no-tags --branch two . dir_tag_no_tags &&
58 # advance both "master" and "side" branches
59 git checkout side &&
60 echo five >file &&
61 git commit -a -m five &&
62 git checkout master &&
63 echo six >file &&
64 git commit -a -m six &&
66 # update tag
67 git tag -d two && git tag two
70 test_expect_success 'by default all branches will be kept updated' '
72 cd dir_all &&
73 git fetch &&
74 git for-each-ref refs/remotes/origin |
75 sed -e "/HEAD$/d" \
76 -e "s|/remotes/origin/|/heads/|" >../actual
77 ) &&
78 # follow both master and side
79 git for-each-ref refs/heads >expect &&
80 test_cmp expect actual
83 test_expect_success 'by default no tags will be kept updated' '
85 cd dir_all &&
86 git fetch &&
87 git for-each-ref refs/tags >../actual
88 ) &&
89 git for-each-ref refs/tags >expect &&
90 test_must_fail test_cmp expect actual &&
91 test_line_count = 2 actual
94 test_expect_success 'clone with --no-tags' '
96 cd dir_all_no_tags &&
97 git fetch &&
98 git for-each-ref refs/tags >../actual
99 ) &&
100 >expect &&
101 test_cmp expect actual
104 test_expect_success '--single-branch while HEAD pointing at master' '
106 cd dir_master &&
107 git fetch &&
108 git for-each-ref refs/remotes/origin |
109 sed -e "/HEAD$/d" \
110 -e "s|/remotes/origin/|/heads/|" >../actual
111 ) &&
112 # only follow master
113 git for-each-ref refs/heads/master >expect &&
114 # get & check latest tags
115 test_cmp expect actual &&
117 cd dir_master &&
118 git fetch --tags &&
119 git for-each-ref refs/tags >../actual
120 ) &&
121 git for-each-ref refs/tags >expect &&
122 test_cmp expect actual &&
123 test_line_count = 2 actual
126 test_expect_success '--single-branch while HEAD pointing at master and --no-tags' '
128 cd dir_master_no_tags &&
129 git fetch &&
130 git for-each-ref refs/remotes/origin |
131 sed -e "/HEAD$/d" \
132 -e "s|/remotes/origin/|/heads/|" >../actual
133 ) &&
134 # only follow master
135 git for-each-ref refs/heads/master >expect &&
136 test_cmp expect actual &&
137 # get tags (noop)
139 cd dir_master_no_tags &&
140 git fetch &&
141 git for-each-ref refs/tags >../actual
142 ) &&
143 >expect &&
144 test_cmp expect actual &&
145 test_line_count = 0 actual &&
146 # get tags with --tags overrides tagOpt
148 cd dir_master_no_tags &&
149 git fetch --tags &&
150 git for-each-ref refs/tags >../actual
151 ) &&
152 git for-each-ref refs/tags >expect &&
153 test_cmp expect actual &&
154 test_line_count = 2 actual
157 test_expect_success '--single-branch while HEAD pointing at side' '
159 cd dir_side &&
160 git fetch &&
161 git for-each-ref refs/remotes/origin |
162 sed -e "/HEAD$/d" \
163 -e "s|/remotes/origin/|/heads/|" >../actual
164 ) &&
165 # only follow side
166 git for-each-ref refs/heads/side >expect &&
167 test_cmp expect actual
170 test_expect_success '--single-branch with explicit --branch side' '
172 cd dir_side2 &&
173 git fetch &&
174 git for-each-ref refs/remotes/origin |
175 sed -e "/HEAD$/d" \
176 -e "s|/remotes/origin/|/heads/|" >../actual
177 ) &&
178 # only follow side
179 git for-each-ref refs/heads/side >expect &&
180 test_cmp expect actual
183 test_expect_success '--single-branch with explicit --branch with tag fetches updated tag' '
185 cd dir_tag &&
186 git fetch &&
187 git for-each-ref refs/tags >../actual
188 ) &&
189 git for-each-ref refs/tags >expect &&
190 test_cmp expect actual
193 test_expect_success '--single-branch with explicit --branch with tag fetches updated tag despite --no-tags' '
195 cd dir_tag_no_tags &&
196 git fetch &&
197 git for-each-ref refs/tags >../actual
198 ) &&
199 git for-each-ref refs/tags/two >expect &&
200 test_cmp expect actual &&
201 test_line_count = 1 actual
204 test_expect_success '--single-branch with --mirror' '
206 cd dir_mirror &&
207 git fetch &&
208 git for-each-ref refs > ../actual
209 ) &&
210 git for-each-ref refs >expect &&
211 test_cmp expect actual
214 test_expect_success '--single-branch with explicit --branch and --mirror' '
216 cd dir_mirror_side &&
217 git fetch &&
218 git for-each-ref refs > ../actual
219 ) &&
220 git for-each-ref refs >expect &&
221 test_cmp expect actual
224 test_expect_success '--single-branch with detached' '
226 cd dir_detached &&
227 git fetch &&
228 git for-each-ref refs/remotes/origin |
229 sed -e "/HEAD$/d" \
230 -e "s|/remotes/origin/|/heads/|" >../actual
231 ) &&
232 # nothing
233 >expect &&
234 test_cmp expect actual
237 test_done