Skip to content

Commit 08bf6a8

Browse files
avargitster
authored andcommitted
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 aedcb7d (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ffdd02a commit 08bf6a8

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

t/t3203-branch-output.sh

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,63 @@ EOF
210210
test_i18ncmp expect actual
211211
'
212212

213-
test_expect_success 'git branch `--sort` option' '
213+
test_expect_success 'git branch `--sort=[-]objectsize` option' '
214214
cat >expect <<-\EOF &&
215215
* (HEAD detached from fromtag)
216216
branch-two
217217
branch-one
218218
main
219219
EOF
220220
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 &&
221270
test_i18ncmp expect actual
222271
'
223272

0 commit comments

Comments
 (0)