Skip to content

Commit b2c51b7

Browse files
derrickstoleegitster
authored andcommitted
for-each-ref: explicitly test no matches
The for-each-ref builtin can take a list of ref patterns, but if none match, it still succeeds (but with no output). Add an explicit test that demonstrates that behavior. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b73dec5 commit b2c51b7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

t/t6300-for-each-ref.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,4 +1501,17 @@ test_expect_success 'git for-each-ref --stdin: matches' '
15011501
test_cmp expect actual
15021502
'
15031503

1504+
test_expect_success 'git for-each-ref with non-existing refs' '
1505+
cat >in <<-EOF &&
1506+
refs/heads/this-ref-does-not-exist
1507+
refs/tags/bogus
1508+
EOF
1509+
1510+
git for-each-ref --format="%(refname)" --stdin <in >actual &&
1511+
test_must_be_empty actual &&
1512+
1513+
xargs git for-each-ref --format="%(refname)" <in >actual &&
1514+
test_must_be_empty actual
1515+
'
1516+
15041517
test_done

0 commit comments

Comments
 (0)