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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Sep 15, 2011 at 23:10 UTC 629cd3ac6d081b43c8cdb045845be1fedbc89615
1 file changed +4 -2
refs.c
+4 -2
@@ -500,6 +500,7 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
500 ssize_t len;
501 char buffer[256];
502 static char ref_buffer[256];
503 + char path[PATH_MAX];
504
505 if (flag)
506 *flag = 0;
@@ -508,7 +509,6 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
509 return NULL;
510
511 for (;;) {
511 - char path[PATH_MAX];
512 struct stat st;
513 char *buf;
514 int fd;
@@ -593,8 +593,10 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
593 if (flag)
594 *flag |= REF_ISSYMREF;
595 }
596 - if (get_sha1_hex(buffer, sha1))
596 + if (get_sha1_hex(buffer, sha1)) {
597 + warning("reference in %s is formatted incorrectly", path);
598 return NULL;
599 + }
600 return ref;
601 }
602