]> git.99rst.org Git - git.git/commitdiff
for-each-ref: explicitly test no matches
authorDerrick Stolee <redacted>
Mon, 20 Mar 2023 11:26:48 +0000 (11:26 +0000)
committerJunio C Hamano <redacted>
Mon, 20 Mar 2023 19:17:32 +0000 (12:17 -0700)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
t/t6300-for-each-ref.sh

index a58053a54c5c37a7cd32a6d855c9512098a96027..6614469d2d63eff2a2cc474d5bc311c64104eeda 100755 (executable)
@@ -1501,4 +1501,17 @@ test_expect_success 'git for-each-ref --stdin: matches' '
        test_cmp expect actual
 '
 
+test_expect_success 'git for-each-ref with non-existing refs' '
+       cat >in <<-EOF &&
+       refs/heads/this-ref-does-not-exist
+       refs/tags/bogus
+       EOF
+
+       git for-each-ref --format="%(refname)" --stdin <in >actual &&
+       test_must_be_empty actual &&
+
+       xargs git for-each-ref --format="%(refname)" <in >actual &&
+       test_must_be_empty actual
+'
+
 test_done
git clone https://git.99rst.org/PROJECT