read_cache_1() and write_cache_1() takes an extra parameter
*sha1 that returns the checksum of the index file when non-NULL.
Signed-off-by: Junio C Hamano <junkio@cox.net>
@ -496,10 +496,12 @@ int add_cache_entry(struct cache_entry *ce, int option)
@@ -496,10 +496,12 @@ int add_cache_entry(struct cache_entry *ce, int option)
return 0;
}
static int verify_hdr(struct cache_header *hdr, unsigned long size)
static int verify_hdr(struct cache_header *hdr, unsigned long size, unsigned char *sha1)
{
SHA_CTX c;
unsigned char sha1[20];
unsigned char sha1_buf[20];
if (!sha1)
sha1 = sha1_buf;
if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
return error("bad signature");
@ -513,7 +515,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
@@ -513,7 +515,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
return 0;
}
int read_cache(void)
int read_cache_1(unsigned char *cache_sha1)
{
int fd, i;
struct stat st;
@ -547,7 +549,7 @@ int read_cache(void)
@@ -547,7 +549,7 @@ int read_cache(void)
@ -595,7 +597,7 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
@@ -595,7 +597,7 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
return 0;
}
static int ce_flush(SHA_CTX *context, int fd)
static int ce_flush(SHA_CTX *context, int fd, unsigned char *sha1)
{
unsigned int left = write_buffer_len;
@ -612,7 +614,8 @@ static int ce_flush(SHA_CTX *context, int fd)
@@ -612,7 +614,8 @@ static int ce_flush(SHA_CTX *context, int fd)