Merge branch 'bc/rev-parse-parseopt-fix'
[gitweb.git] / cache.h
diff --git a/cache.h b/cache.h
index 49b083ee0a10ea379f271e141ccee0fa852a1954..ea6c236e0fa5e895d89a0029349ea54f9afabd07 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1244,8 +1244,8 @@ static inline unsigned int hexval(unsigned char c)
  */
 static inline int hex2chr(const char *s)
 {
-       int val = hexval(s[0]);
-       return (val < 0) ? val : (val << 4) | hexval(s[1]);
+       unsigned int val = hexval(s[0]);
+       return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
 }
 
 /* Convert to/from hex/sha1 representation */