提交 025a0709 编写于 作者: J Junio C Hamano 提交者: Linus Torvalds

[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: NJunio C Hamano <junkio@cox.net>

Oops.
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 aa16021e
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册