Clean up RelNotes for 2.48
[alt-git.git] / t / t5612-clone-refspec.sh
blob72762de9774caa7a3d02b6a3539cd3372b24c3ad
1 #!/bin/sh
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
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 test_expect_success 'setup' '
11 # Make two branches, "main" and "side"
12 echo one >file &&
13 git add file &&
14 git commit -m one &&
15 echo two >file &&
16 git commit -a -m two &&
17 git tag two &&
18 echo three >file &&
19 git commit -a -m three &&
20 git checkout -b side &&
21 echo four >file &&
22 git commit -a -m four &&
23 git checkout main &&
24 git tag five &&
26 # default clone
27 git clone . dir_all &&
29 # default clone --no-tags
30 git clone --no-tags . dir_all_no_tags &&
32 # default --single that follows HEAD=main
33 git clone --single-branch . dir_main &&
35 # default --single that follows HEAD=main with no tags
36 git clone --single-branch --no-tags . dir_main_no_tags &&
38 # default --single that follows HEAD=side
39 git checkout side &&
40 git clone --single-branch . dir_side &&
42 # explicit --single that follows side
43 git checkout main &&
44 git clone --single-branch --branch side . dir_side2 &&
46 # default --single with --mirror
47 git clone --single-branch --mirror . dir_mirror &&
49 # default --single with --branch and --mirror
50 git clone --single-branch --mirror --branch side . dir_mirror_side &&
52 # --single that does not know what branch to follow
53 git checkout two^ &&
54 git clone --single-branch . dir_detached &&
56 # explicit --single with tag
57 git clone --single-branch --branch two . dir_tag &&
59 # explicit --single with tag and --no-tags
60 git clone --single-branch --no-tags --branch two . dir_tag_no_tags &&
62 # advance both "main" and "side" branches
63 git checkout side &&
64 echo five >file &&
65 git commit -a -m five &&
66 git checkout main &&
67 echo six >file &&
68 git commit -a -m six &&
70 # update tag
71 git tag -d two && git tag two
74 test_expect_success 'by default all branches will be kept updated' '
76 cd dir_all &&
77 git fetch &&
78 git for-each-ref refs/remotes/origin >refs &&
79 sed -e "/HEAD$/d" \
80 -e "s|/remotes/origin/|/heads/|" refs >../actual
81 ) &&
82 # follow both main and side
83 git for-each-ref refs/heads >expect &&
84 test_cmp expect actual
87 test_expect_success 'by default no tags will be kept updated' '
89 cd dir_all &&
90 git fetch &&
91 git for-each-ref refs/tags >../actual
92 ) &&
93 git for-each-ref refs/tags >expect &&
94 ! test_cmp expect actual &&
95 test_line_count = 2 actual
98 test_expect_success 'clone with --no-tags' '
100 cd dir_all_no_tags &&
101 grep tagOpt .git/config &&
102 git fetch &&
103 git for-each-ref refs/tags >../actual
104 ) &&
105 test_must_be_empty actual
108 test_expect_success '--single-branch while HEAD pointing at main' '
110 cd dir_main &&
111 git fetch --force &&
112 git for-each-ref refs/remotes/origin >refs &&
113 sed -e "/HEAD$/d" \
114 -e "s|/remotes/origin/|/heads/|" refs >../actual
115 ) &&
116 # only follow main
117 git for-each-ref refs/heads/main >expect &&
118 # get & check latest tags
119 test_cmp expect actual &&
121 cd dir_main &&
122 git fetch --tags --force &&
123 git for-each-ref refs/tags >../actual
124 ) &&
125 git for-each-ref refs/tags >expect &&
126 test_cmp expect actual &&
127 test_line_count = 2 actual
130 test_expect_success '--single-branch while HEAD pointing at main and --no-tags' '
132 cd dir_main_no_tags &&
133 git fetch &&
134 git for-each-ref refs/remotes/origin >refs &&
135 sed -e "/HEAD$/d" \
136 -e "s|/remotes/origin/|/heads/|" refs >../actual
137 ) &&
138 # only follow main
139 git for-each-ref refs/heads/main >expect &&
140 test_cmp expect actual &&
141 # get tags (noop)
143 cd dir_main_no_tags &&
144 git fetch &&
145 git for-each-ref refs/tags >../actual
146 ) &&
147 test_must_be_empty actual &&
148 test_line_count = 0 actual &&
149 # get tags with --tags overrides tagOpt
151 cd dir_main_no_tags &&
152 git fetch --tags &&
153 git for-each-ref refs/tags >../actual
154 ) &&
155 git for-each-ref refs/tags >expect &&
156 test_cmp expect actual &&
157 test_line_count = 2 actual
160 test_expect_success '--single-branch while HEAD pointing at side' '
162 cd dir_side &&
163 git fetch &&
164 git for-each-ref refs/remotes/origin >refs &&
165 sed -e "/HEAD$/d" \
166 -e "s|/remotes/origin/|/heads/|" refs >../actual
167 ) &&
168 # only follow side
169 git for-each-ref refs/heads/side >expect &&
170 test_cmp expect actual
173 test_expect_success '--single-branch with explicit --branch side' '
175 cd dir_side2 &&
176 git fetch &&
177 git for-each-ref refs/remotes/origin >refs &&
178 sed -e "/HEAD$/d" \
179 -e "s|/remotes/origin/|/heads/|" refs >../actual
180 ) &&
181 # only follow side
182 git for-each-ref refs/heads/side >expect &&
183 test_cmp expect actual
186 test_expect_success '--single-branch with explicit --branch with tag fetches updated tag' '
188 cd dir_tag &&
189 git fetch &&
190 git for-each-ref refs/tags >../actual
191 ) &&
192 git for-each-ref refs/tags >expect &&
193 test_cmp expect actual
196 test_expect_success '--single-branch with explicit --branch with tag fetches updated tag despite --no-tags' '
198 cd dir_tag_no_tags &&
199 git fetch &&
200 git for-each-ref refs/tags >../actual
201 ) &&
202 git for-each-ref refs/tags/two >expect &&
203 test_cmp expect actual &&
204 test_line_count = 1 actual
207 test_expect_success '--single-branch with --mirror' '
209 cd dir_mirror &&
210 git fetch &&
211 git for-each-ref refs > ../actual
212 ) &&
213 git for-each-ref refs >expect &&
214 test_cmp expect actual
217 test_expect_success '--single-branch with explicit --branch and --mirror' '
219 cd dir_mirror_side &&
220 git fetch &&
221 git for-each-ref refs > ../actual
222 ) &&
223 git for-each-ref refs >expect &&
224 test_cmp expect actual
227 test_expect_success '--single-branch with detached' '
229 cd dir_detached &&
230 git fetch &&
231 git for-each-ref refs/remotes/origin >refs &&
232 sed -e "/HEAD$/d" \
233 -e "s|/remotes/origin/|/heads/|" refs >../actual
234 ) &&
235 # nothing
236 test_must_be_empty actual
239 test_done