branch tests: add to --sort tests

Further stress the --sort callback in ref-filter.c. The implementation uses certain short-circuiting logic, let's make sure it behaves the same way on e.g. name & version sort. Improves a test added in aedcb7dc75e (branch.c: use 'ref-filter' APIs, 2015-09-23). I don't think all of this output makes sense, but let's test for the behavior as-is, we can fix bugs in it in a later commit. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jan 6, 2021 at 11:01 UTC 08bf6a8bc351a720f07e1afecb46b1bfae64c7ab
1 file changed +50 -1
t/t3203-branch-output.sh
+50 -1
@@ -210,7 +210,7 @@ EOF
210 test_i18ncmp expect actual
211 '
212
213 -test_expect_success 'git branch `--sort` option' '
213 +test_expect_success 'git branch `--sort=[-]objectsize` option' '
214 cat >expect <<-\EOF &&
215 * (HEAD detached from fromtag)
216 branch-two
@@ -218,6 +218,55 @@ test_expect_success 'git branch `--sort` option' '
218 main
219 EOF
220 git branch --sort=objectsize >actual &&
221 + test_i18ncmp expect actual &&
222 +
223 + cat >expect <<-\EOF &&
224 + branch-one
225 + main
226 + * (HEAD detached from fromtag)
227 + branch-two
228 + EOF
229 + git branch --sort=-objectsize >actual &&
230 + test_i18ncmp expect actual
231 +'
232 +
233 +test_expect_success 'git branch `--sort=[-]type` option' '
234 + cat >expect <<-\EOF &&
235 + * (HEAD detached from fromtag)
236 + branch-one
237 + branch-two
238 + main
239 + EOF
240 + git branch --sort=type >actual &&
241 + test_i18ncmp expect actual &&
242 +
243 + cat >expect <<-\EOF &&
244 + * (HEAD detached from fromtag)
245 + branch-one
246 + branch-two
247 + main
248 + EOF
249 + git branch --sort=-type >actual &&
250 + test_i18ncmp expect actual
251 +'
252 +
253 +test_expect_success 'git branch `--sort=[-]version:refname` option' '
254 + cat >expect <<-\EOF &&
255 + * (HEAD detached from fromtag)
256 + branch-one
257 + branch-two
258 + main
259 + EOF
260 + git branch --sort=version:refname >actual &&
261 + test_i18ncmp expect actual &&
262 +
263 + cat >expect <<-\EOF &&
264 + main
265 + branch-two
266 + branch-one
267 + * (HEAD detached from fromtag)
268 + EOF
269 + git branch --sort=-version:refname >actual &&
270 test_i18ncmp expect actual
271 '
272