Skip to content

Commit 0136bac

Browse files
committed
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 <[email protected]>
1 parent 936f53d commit 0136bac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

read-cache.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,11 +1247,13 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
12471247
{
12481248
git_SHA_CTX c;
12491249
unsigned char sha1[20];
1250+
int hdr_version;
12501251

12511252
if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
12521253
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);
12551257
git_SHA1_Init(&c);
12561258
git_SHA1_Update(&c, hdr, size - 20);
12571259
git_SHA1_Final(sha1, &c);

0 commit comments

Comments
 (0)