3 test_description
='test refspec written by clone-command'
6 test_expect_success
'setup' '
7 # Make two branches, "master" and "side"
12 git commit -a -m two &&
15 git commit -a -m three &&
16 git checkout -b side &&
18 git commit -a -m four &&
19 git checkout master &&
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
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
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
61 git commit -a -m five &&
62 git checkout master &&
64 git commit -a -m six &&
67 git tag -d two && git tag two
70 test_expect_success
'by default all branches will be kept updated' '
74 git for-each-ref refs/remotes/origin >refs &&
76 -e "s|/remotes/origin/|/heads/|" refs >../actual
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' '
87 git for-each-ref refs/tags >../actual
89 git for-each-ref refs/tags >expect &&
90 ! test_cmp expect actual &&
91 test_line_count = 2 actual
94 test_expect_success
'clone with --no-tags' '
98 git for-each-ref refs/tags >../actual
100 test_must_be_empty actual
103 test_expect_success
'--single-branch while HEAD pointing at master' '
107 git for-each-ref refs/remotes/origin >refs &&
109 -e "s|/remotes/origin/|/heads/|" refs >../actual
112 git for-each-ref refs/heads/master >expect &&
113 # get & check latest tags
114 test_cmp expect actual &&
117 git fetch --tags --force &&
118 git for-each-ref refs/tags >../actual
120 git for-each-ref refs/tags >expect &&
121 test_cmp expect actual &&
122 test_line_count = 2 actual
125 test_expect_success
'--single-branch while HEAD pointing at master and --no-tags' '
127 cd dir_master_no_tags &&
129 git for-each-ref refs/remotes/origin >refs &&
131 -e "s|/remotes/origin/|/heads/|" refs >../actual
134 git for-each-ref refs/heads/master >expect &&
135 test_cmp expect actual &&
138 cd dir_master_no_tags &&
140 git for-each-ref refs/tags >../actual
142 test_must_be_empty actual &&
143 test_line_count = 0 actual &&
144 # get tags with --tags overrides tagOpt
146 cd dir_master_no_tags &&
148 git for-each-ref refs/tags >../actual
150 git for-each-ref refs/tags >expect &&
151 test_cmp expect actual &&
152 test_line_count = 2 actual
155 test_expect_success
'--single-branch while HEAD pointing at side' '
159 git for-each-ref refs/remotes/origin >refs &&
161 -e "s|/remotes/origin/|/heads/|" refs >../actual
164 git for-each-ref refs/heads/side >expect &&
165 test_cmp expect actual
168 test_expect_success
'--single-branch with explicit --branch side' '
172 git for-each-ref refs/remotes/origin >refs &&
174 -e "s|/remotes/origin/|/heads/|" refs >../actual
177 git for-each-ref refs/heads/side >expect &&
178 test_cmp expect actual
181 test_expect_success
'--single-branch with explicit --branch with tag fetches updated tag' '
185 git for-each-ref refs/tags >../actual
187 git for-each-ref refs/tags >expect &&
188 test_cmp expect actual
191 test_expect_success
'--single-branch with explicit --branch with tag fetches updated tag despite --no-tags' '
193 cd dir_tag_no_tags &&
195 git for-each-ref refs/tags >../actual
197 git for-each-ref refs/tags/two >expect &&
198 test_cmp expect actual &&
199 test_line_count = 1 actual
202 test_expect_success
'--single-branch with --mirror' '
206 git for-each-ref refs > ../actual
208 git for-each-ref refs >expect &&
209 test_cmp expect actual
212 test_expect_success
'--single-branch with explicit --branch and --mirror' '
214 cd dir_mirror_side &&
216 git for-each-ref refs > ../actual
218 git for-each-ref refs >expect &&
219 test_cmp expect actual
222 test_expect_success
'--single-branch with detached' '
226 git for-each-ref refs/remotes/origin >refs &&
228 -e "s|/remotes/origin/|/heads/|" refs >../actual
231 test_must_be_empty actual