diff options
| author | Øystein Walle <oystwa@gmail.com> | 2023-04-07 19:53:16 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-04-13 08:07:45 -0700 |
| commit | aabfdc9514a51d8d9a2f3afbc29e5044ccf7191b (patch) | |
| tree | ce139c4fbbe04454b87b128865b2047f8ae5070f /t/t3203-branch-output.sh | |
| parent | 73876f4861cd3d187a4682290ab75c9dccadbc56 (diff) | |
| download | git-aabfdc9514a51d8d9a2f3afbc29e5044ccf7191b.tar.gz | |
branch, for-each-ref, tag: add option to omit empty lines
If the given format string expands to the empty string, a newline is
still printed. This makes using the output linewise more tedious. For
example, git update-ref --stdin does not accept empty lines.
Add options to "git branch", "git for-each-ref", and "git tag" to
not print these empty lines. The default behavior remains the same.
Signed-off-by: Øystein Walle <oystwa@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3203-branch-output.sh')
| -rwxr-xr-x | t/t3203-branch-output.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index d34d77f893..c06906d83e 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -341,6 +341,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> |
