Skip to content

Commit 971c41c

Browse files
rsahlberggitster
authored andcommitted
for-each-ref: skip and warn about broken ref names
Print a warning message for any bad ref names we find in the repo and skip them so callers don't have to deal with parsing them. It might be useful in the future to have a flag where we would not skip these refs for those callers that want to and are prepared (for example by using a --format argument with %0 as a delimiter after the ref name). Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0f810f commit 971c41c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

builtin/for-each-ref.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,11 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
839839
struct refinfo *ref;
840840
int cnt;
841841

842+
if (flag & REF_BAD_NAME) {
843+
warning("ignoring ref with broken name %s", refname);
844+
return 0;
845+
}
846+
842847
if (*cb->grab_pattern) {
843848
const char **pattern;
844849
int namelen = strlen(refname);

0 commit comments

Comments
 (0)