aboutsummaryrefslogtreecommitdiffstats
path: root/t/t3203-branch-output.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-04-21 15:35:05 -0700
committerJunio C Hamano <gitster@pobox.com>2023-04-21 15:35:05 -0700
commitb64894c2063e5875bfd95b537eafcb3e1abf46ff (patch)
tree989d1d734418b366f23738b228b96dcd6ec1acbd /t/t3203-branch-output.sh
parentMerge branch 'ah/format-patch-thread-doc' (diff)
parentbranch, for-each-ref, tag: add option to omit empty lines (diff)
downloadgit-b64894c2063e5875bfd95b537eafcb3e1abf46ff.tar.gz
git-b64894c2063e5875bfd95b537eafcb3e1abf46ff.zip
Merge branch 'ow/ref-filter-omit-empty'
"git branch --format=..." and "git format-patch --format=..." learns "--omit-empty" to hide refs that whose formatting result becomes an empty string from the output. * ow/ref-filter-omit-empty: branch, for-each-ref, tag: add option to omit empty lines
Diffstat (limited to 't/t3203-branch-output.sh')
-rwxr-xr-xt/t3203-branch-output.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index 1c0f7ea24e..93f8295339 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -355,6 +355,30 @@ test_expect_success 'git branch with --format=%(rest) must fail' '
test_must_fail git branch --format="%(rest)" >actual
'
+test_expect_success 'git branch --format --omit-empty' '
+ cat >expect <<-\EOF &&
+ Refname is (HEAD detached from fromtag)
+ Refname is refs/heads/ambiguous
+ Refname is refs/heads/branch-one
+ Refname is refs/heads/branch-two
+
+ Refname is refs/heads/ref-to-branch
+ Refname is refs/heads/ref-to-remote
+ EOF
+ git branch --format="%(if:notequals=refs/heads/main)%(refname)%(then)Refname is %(refname)%(end)" >actual &&
+ test_cmp expect actual &&
+ cat >expect <<-\EOF &&
+ Refname is (HEAD detached from fromtag)
+ Refname is refs/heads/ambiguous
+ Refname is refs/heads/branch-one
+ Refname is refs/heads/branch-two
+ Refname is refs/heads/ref-to-branch
+ Refname is refs/heads/ref-to-remote
+ EOF
+ git branch --omit-empty --format="%(if:notequals=refs/heads/main)%(refname)%(then)Refname is %(refname)%(end)" >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'worktree colors correct' '
cat >expect <<-EOF &&
* <GREEN>(HEAD detached from fromtag)<RESET>