Skip to content

Commit 629cd3a

Browse files
mhaggergitster
authored andcommitted
resolve_ref(): emit warnings for improperly-formatted references
While resolving references, if a reference is found that is in an unrecognized format, emit a warning (and then fail, as before). Wouldn't *you* want to know? Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8384d78 commit 629cd3a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

refs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
500500
ssize_t len;
501501
char buffer[256];
502502
static char ref_buffer[256];
503+
char path[PATH_MAX];
503504

504505
if (flag)
505506
*flag = 0;
@@ -508,7 +509,6 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
508509
return NULL;
509510

510511
for (;;) {
511-
char path[PATH_MAX];
512512
struct stat st;
513513
char *buf;
514514
int fd;
@@ -593,8 +593,10 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
593593
if (flag)
594594
*flag |= REF_ISSYMREF;
595595
}
596-
if (get_sha1_hex(buffer, sha1))
596+
if (get_sha1_hex(buffer, sha1)) {
597+
warning("reference in %s is formatted incorrectly", path);
597598
return NULL;
599+
}
598600
return ref;
599601
}
600602

0 commit comments

Comments
 (0)