summaryrefslogtreecommitdiff
path: root/t/t3203-branch-output.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t3203-branch-output.sh')
-rwxr-xr-xt/t3203-branch-output.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index 500c9d0e72..a6bd88a58d 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -368,6 +368,34 @@ test_expect_success 'git branch --format with ahead-behind' '
test_cmp expect actual
'
+test_expect_success 'git branch `--sort=[-]ahead-behind` option' '
+ cat >expect <<-\EOF &&
+ (HEAD detached from fromtag) 0 0
+ refs/heads/ambiguous 0 0
+ refs/heads/branch-two 0 0
+ refs/heads/branch-one 1 0
+ refs/heads/main 1 0
+ refs/heads/ref-to-branch 1 0
+ refs/heads/ref-to-remote 1 0
+ EOF
+ git branch --format="%(refname) %(ahead-behind:HEAD)" \
+ --sort=refname --sort=ahead-behind:HEAD >actual &&
+ test_cmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ (HEAD detached from fromtag) 0 0
+ refs/heads/branch-one 1 0
+ refs/heads/main 1 0
+ refs/heads/ref-to-branch 1 0
+ refs/heads/ref-to-remote 1 0
+ refs/heads/ambiguous 0 0
+ refs/heads/branch-two 0 0
+ EOF
+ git branch --format="%(refname) %(ahead-behind:HEAD)" \
+ --sort=refname --sort=-ahead-behind:HEAD >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'git branch with --format=%(rest) must fail' '
test_must_fail git branch --format="%(rest)" >actual
'