[PATCH v3 19/22] resolve_ref(): emit warnings for improperly-formatted references
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Sep 15, 2011, 21:10 UTC
- Message-ID
- <1316121043-29367-20-git-send-email-mhagger@alum.mit.edu>
- In-Reply-To
- <1316121043-29367-1-git-send-email-mhagger@alum.mit.edu>
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> --- refs.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/refs.c b/refs.c index ee3e0cc..2387f4e 100644 --- a/refs.c +++ b/refs.c @@ -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; @@ -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; @@ -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; }
-- 1.7.6.8.gd2879