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>

Junio C Hamano committed Apr 3, 2012 at 15:53 UTC 0136bac9b8a449cdf2179ad0242e079262b0aeea
1 file changed +4 -2
read-cache.c
+4 -2
@@ -1247,11 +1247,13 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
1247 {
1248 git_SHA_CTX c;
1249 unsigned char sha1[20];
1250 + int hdr_version;
1251
1252 if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
1253 return error("bad signature");
1253 - if (hdr->hdr_version != htonl(2) && hdr->hdr_version != htonl(3))
1254 - return error("bad index version");
1254 + hdr_version = ntohl(hdr->hdr_version);
1255 + if (hdr_version < 2 || 3 < hdr_version)
1256 + return error("bad index version %d", hdr_version);
1257 git_SHA1_Init(&c);
1258 git_SHA1_Update(&c, hdr, size - 20);
1259 git_SHA1_Final(sha1, &c);