Skip to content

Commit

Permalink
read-cache.c: report the header version we do not understand
Browse files Browse the repository at this point in the history
Instead of just saying "bad index version", report the value we read
from the disk.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Apr 3, 2012
1 parent 936f53d commit 0136bac
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0136bac

Please sign in to comment.