diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t3203-branch-output.sh | 24 | ||||
-rwxr-xr-x | t/t6300-for-each-ref.sh | 8 | ||||
-rwxr-xr-x | t/t7004-tag.sh | 16 |
3 files changed, 48 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> diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index 6614469d2d..5c00607608 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -1374,6 +1374,14 @@ test_expect_success 'for-each-ref --ignore-case ignores case' ' test_cmp expect actual ' +test_expect_success 'for-each-ref --omit-empty works' ' + git for-each-ref --format="%(refname)" >actual && + test_line_count -gt 1 actual && + git for-each-ref --format="%(if:equals=refs/heads/main)%(refname)%(then)%(refname)%(end)" --omit-empty >actual && + echo refs/heads/main >expect && + test_cmp expect actual +' + test_expect_success 'for-each-ref --ignore-case works on multiple sort keys' ' # name refs numerically to avoid case-insensitive filesystem conflicts nr=0 && diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 32b312fa80..0fe6ba93a2 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -2046,6 +2046,22 @@ test_expect_success '--format should list tags as per format given' ' test_cmp expect actual ' +test_expect_success '--format --omit-empty works' ' + cat >expect <<-\EOF && + refname : refs/tags/v1.0 + + refname : refs/tags/v1.1.3 + EOF + git tag -l --format="%(if:notequals=refs/tags/v1.0.1)%(refname)%(then)refname : %(refname)%(end)" "v1*" >actual && + test_cmp expect actual && + cat >expect <<-\EOF && + refname : refs/tags/v1.0 + refname : refs/tags/v1.1.3 + EOF + git tag -l --omit-empty --format="%(if:notequals=refs/tags/v1.0.1)%(refname)%(then)refname : %(refname)%(end)" "v1*" >actual && + test_cmp expect actual +' + test_expect_success 'git tag -l with --format="%(rest)" must fail' ' test_must_fail git tag -l --format="%(rest)" "v1*" ' |