summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-06-10 08:32:37 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-10 14:42:45 (GMT)
commit025a0709b6179506ffc0d35967bdd4fb804d30fb (patch)
tree1b59113cdd8f9bf33eb26c6334ffdede87a127de /read-cache.c
parentaa16021efcd969a44b480d0964e07d52167517db (diff)
downloadgit-025a0709b6179506ffc0d35967bdd4fb804d30fb.zip
git-025a0709b6179506ffc0d35967bdd4fb804d30fb.tar.gz
git-025a0709b6179506ffc0d35967bdd4fb804d30fb.tar.bz2
[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>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/read-cache.c b/read-cache.c
index d358933..e9618f0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -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)