3 test_description
='test refspec written by clone-command'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 test_expect_success
'setup' '
10 # Make two branches, "main" and "side"
15 git commit -a -m two &&
18 git commit -a -m three &&
19 git checkout -b side &&
21 git commit -a -m four &&
26 git clone . dir_all &&
28 # default clone --no-tags
29 git clone --no-tags . dir_all_no_tags &&
31 # default --single that follows HEAD=main
32 git clone --single-branch . dir_main &&
34 # default --single that follows HEAD=main with no tags
35 git clone --single-branch --no-tags . dir_main_no_tags &&
37 # default --single that follows HEAD=side
39 git clone --single-branch . dir_side &&
41 # explicit --single that follows side
43 git clone --single-branch --branch side . dir_side2 &&
45 # default --single with --mirror
46 git clone --single-branch --mirror . dir_mirror &&
48 # default --single with --branch and --mirror
49 git clone --single-branch --mirror --branch side . dir_mirror_side &&
51 # --single that does not know what branch to follow
53 git clone --single-branch . dir_detached &&
55 # explicit --single with tag
56 git clone --single-branch --branch two . dir_tag &&
58 # explicit --single with tag and --no-tags
59 git clone --single-branch --no-tags --branch two . dir_tag_no_tags &&
61 # advance both "main" and "side" branches
64 git commit -a -m five &&
67 git commit -a -m six &&
70 git tag -d two && git tag two
73 test_expect_success
'by default all branches will be kept updated' '
77 git for-each-ref refs/remotes/origin >refs &&
79 -e "s|/remotes/origin/|/heads/|" refs >../actual
81 # follow both main and side
82 git for-each-ref refs/heads >expect &&
83 test_cmp expect actual
86 test_expect_success
'by default no tags will be kept updated' '
90 git for-each-ref refs/tags >../actual
92 git for-each-ref refs/tags >expect &&
93 ! test_cmp expect actual &&
94 test_line_count = 2 actual
97 test_expect_success
'clone with --no-tags' '
100 grep tagOpt .git/config &&
102 git for-each-ref refs/tags >../actual
104 test_must_be_empty actual
107 test_expect_success
'--single-branch while HEAD pointing at main' '
111 git for-each-ref refs/remotes/origin >refs &&
113 -e "s|/remotes/origin/|/heads/|" refs >../actual
116 git for-each-ref refs/heads/main >expect &&
117 # get & check latest tags
118 test_cmp expect actual &&
121 git fetch --tags --force &&
122 git for-each-ref refs/tags >../actual
124 git for-each-ref refs/tags >expect &&
125 test_cmp expect actual &&
126 test_line_count = 2 actual
129 test_expect_success
'--single-branch while HEAD pointing at main and --no-tags' '
131 cd dir_main_no_tags &&
133 git for-each-ref refs/remotes/origin >refs &&
135 -e "s|/remotes/origin/|/heads/|" refs >../actual
138 git for-each-ref refs/heads/main >expect &&
139 test_cmp expect actual &&
142 cd dir_main_no_tags &&
144 git for-each-ref refs/tags >../actual
146 test_must_be_empty actual &&
147 test_line_count = 0 actual &&
148 # get tags with --tags overrides tagOpt
150 cd dir_main_no_tags &&
152 git for-each-ref refs/tags >../actual
154 git for-each-ref refs/tags >expect &&
155 test_cmp expect actual &&
156 test_line_count = 2 actual
159 test_expect_success
'--single-branch while HEAD pointing at side' '
163 git for-each-ref refs/remotes/origin >refs &&
165 -e "s|/remotes/origin/|/heads/|" refs >../actual
168 git for-each-ref refs/heads/side >expect &&
169 test_cmp expect actual
172 test_expect_success
'--single-branch with explicit --branch side' '
176 git for-each-ref refs/remotes/origin >refs &&
178 -e "s|/remotes/origin/|/heads/|" refs >../actual
181 git for-each-ref refs/heads/side >expect &&
182 test_cmp expect actual
185 test_expect_success
'--single-branch with explicit --branch with tag fetches updated tag' '
189 git for-each-ref refs/tags >../actual
191 git for-each-ref refs/tags >expect &&
192 test_cmp expect actual
195 test_expect_success
'--single-branch with explicit --branch with tag fetches updated tag despite --no-tags' '
197 cd dir_tag_no_tags &&
199 git for-each-ref refs/tags >../actual
201 git for-each-ref refs/tags/two >expect &&
202 test_cmp expect actual &&
203 test_line_count = 1 actual
206 test_expect_success
'--single-branch with --mirror' '
210 git for-each-ref refs > ../actual
212 git for-each-ref refs >expect &&
213 test_cmp expect actual
216 test_expect_success
'--single-branch with explicit --branch and --mirror' '
218 cd dir_mirror_side &&
220 git for-each-ref refs > ../actual
222 git for-each-ref refs >expect &&
223 test_cmp expect actual
226 test_expect_success
'--single-branch with detached' '
230 git for-each-ref refs/remotes/origin >refs &&
232 -e "s|/remotes/origin/|/heads/|" refs >../actual
235 test_must_be_empty actual