diff options
-rw-r--r-- | builtin/for-each-ref.c | 5 | ||||
-rwxr-xr-x | t/t6301-for-each-ref-errors.sh | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 008513c2f..4a15f568f 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -851,6 +851,11 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f return 0; } + if (flag & REF_ISBROKEN) { + warning("ignoring broken ref %s", refname); + return 0; + } + if (*cb->grab_pattern) { const char **pattern; int namelen = strlen(refname); diff --git a/t/t6301-for-each-ref-errors.sh b/t/t6301-for-each-ref-errors.sh index cf25244c2..72d2397e1 100755 --- a/t/t6301-for-each-ref-errors.sh +++ b/t/t6301-for-each-ref-errors.sh @@ -14,7 +14,7 @@ test_expect_success setup ' git for-each-ref --format="%(objectname) %(refname)" >brief-list ' -test_expect_failure 'Broken refs are reported correctly' ' +test_expect_success 'Broken refs are reported correctly' ' r=refs/heads/bogus && : >.git/$r && test_when_finished "rm -f .git/$r" && |