1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-19 16:26:09 +02:00

[PATCH] Bugfix: read-cache.c:write_cache() misrecords number of entries.

When we choose to omit deleted entries, we should subtract
numbers of such entries from the total number in the header.

Signed-off-by: Junio C Hamano <junkio@cox.net>

Oops.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Junio C Hamano 2005-06-10 01:32:37 -07:00 committed by Linus Torvalds
parent aa16021efc
commit 025a0709b6

View File

@ -440,11 +440,15 @@ int write_cache(int newfd, struct cache_entry **cache, int entries)
{
SHA_CTX c;
struct cache_header hdr;
int i;
int i, removed;
for (i = removed = 0; i < entries; i++)
if (!cache[i]->ce_mode)
removed++;
hdr.hdr_signature = htonl(CACHE_SIGNATURE);
hdr.hdr_version = htonl(2);
hdr.hdr_entries = htonl(entries);
hdr.hdr_entries = htonl(entries - removed);
SHA1_Init(&c);
if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)