summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-04-03 22:53:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-04-03 23:24:45 (GMT)
commit0136bac9b8a449cdf2179ad0242e079262b0aeea (patch)
tree62637aa5f32b62e3248e3bb5786fb27ac198aea6 /read-cache.c
parent936f53d055c9a336e9ad89ad06c4efd56e5896e8 (diff)
downloadgit-0136bac9b8a449cdf2179ad0242e079262b0aeea.zip
git-0136bac9b8a449cdf2179ad0242e079262b0aeea.tar.gz
git-0136bac9b8a449cdf2179ad0242e079262b0aeea.tar.bz2
read-cache.c: report the header version we do not understand
Instead of just saying "bad index version", report the value we read from the disk. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/read-cache.c b/read-cache.c
index 58bfb24..2d93826 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1247,11 +1247,13 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
{
git_SHA_CTX c;
unsigned char sha1[20];
+ int hdr_version;
if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
return error("bad signature");
- if (hdr->hdr_version != htonl(2) && hdr->hdr_version != htonl(3))
- return error("bad index version");
+ hdr_version = ntohl(hdr->hdr_version);
+ if (hdr_version < 2 || 3 < hdr_version)
+ return error("bad index version %d", hdr_version);
git_SHA1_Init(&c);
git_SHA1_Update(&c, hdr, size - 20);
git_SHA1_Final(sha1, &c);