Skip to content

Commit

Permalink
resolve_ref(): emit warnings for improperly-formatted references
Browse files Browse the repository at this point in the history
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 <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Oct 5, 2011
1 parent 8384d78 commit 629cd3a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
ssize_t len;
char buffer[256];
static char ref_buffer[256];
char path[PATH_MAX];

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

for (;;) {
char path[PATH_MAX];
struct stat st;
char *buf;
int fd;
Expand Down Expand Up @@ -593,8 +593,10 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
if (flag)
*flag |= REF_ISSYMREF;
}
if (get_sha1_hex(buffer, sha1))
if (get_sha1_hex(buffer, sha1)) {
warning("reference in %s is formatted incorrectly", path);
return NULL;
}
return ref;
}

Expand Down

0 comments on commit 629cd3a

Please sign in to comment.