summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-02-08 23:05:55 +0100
committerJunio C Hamano <gitster@pobox.com>2021-02-08 23:05:55 +0100
commitf2d156dc4891dc1f0e86907fe20d3ac08d3cfde1 (patch)
treed7459e3da29b75acc4b3ab4d865bb1a77855362a /t
parentMerge branch 'ma/more-opaque-lock-file' into maint (diff)
parentbranch: show "HEAD detached" first under reverse sort (diff)
downloadgit-f2d156dc4891dc1f0e86907fe20d3ac08d3cfde1.tar.xz
git-f2d156dc4891dc1f0e86907fe20d3ac08d3cfde1.zip
Merge branch 'ab/branch-sort' into maint
The implementation of "git branch --sort" wrt the detached HEAD display has always been hacky, which has been cleaned up. * ab/branch-sort: branch: show "HEAD detached" first under reverse sort branch: sort detached HEAD based on a flag ref-filter: move ref_sorting flags to a bitfield ref-filter: move "cmp_fn" assignment into "else if" arm ref-filter: add braces to if/else if/else chain branch tests: add to --sort tests branch: change "--local" to "--list" in comment
Diffstat (limited to 't')
-rwxr-xr-xt/t3203-branch-output.sh51
1 files changed, 50 insertions, 1 deletions
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index b945faf470..5e0577d5c7 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -210,7 +210,7 @@ EOF
test_i18ncmp expect actual
'
-test_expect_success 'git branch `--sort` option' '
+test_expect_success 'git branch `--sort=[-]objectsize` option' '
cat >expect <<-\EOF &&
* (HEAD detached from fromtag)
branch-two
@@ -218,6 +218,55 @@ test_expect_success 'git branch `--sort` option' '
main
EOF
git branch --sort=objectsize >actual &&
+ test_i18ncmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ branch-one
+ main
+ branch-two
+ EOF
+ git branch --sort=-objectsize >actual &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'git branch `--sort=[-]type` option' '
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ branch-one
+ branch-two
+ main
+ EOF
+ git branch --sort=type >actual &&
+ test_i18ncmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ branch-one
+ branch-two
+ main
+ EOF
+ git branch --sort=-type >actual &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'git branch `--sort=[-]version:refname` option' '
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ branch-one
+ branch-two
+ main
+ EOF
+ git branch --sort=version:refname >actual &&
+ test_i18ncmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
+ main
+ branch-two
+ branch-one
+ EOF
+ git branch --sort=-version:refname >actual &&
test_i18ncmp expect actual
'