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 <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Mar 20, 2023 at 11:26 UTC
b2c51b75902acfbb8ab8ac9aadc919bf5a447c1b
1 file changed
+13
t/t6300-for-each-ref.sh
+13
@@ -1501,4 +1501,17 @@ test_expect_success 'git for-each-ref --stdin: matches' '
1501
test_cmp expect actual
1502
'
1503
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
+
1517
test_done