diff options
author | Nicolas Pitre <nico@cam.org> | 2007-12-07 20:27:52 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-08 03:38:35 -0800 |
commit | b7a28f7827ba1043501fe357cbbdff3f2e357143 (patch) | |
tree | 49133e60e490ffc62140bbf2d396de0491c7e25c /builtin-pack-objects.c | |
parent | 2099bca9ed06a4cb7ab0b8ca38bc90df5632ba41 (diff) | |
download | git-b7a28f7827ba1043501fe357cbbdff3f2e357143.tar.gz |
pack-objects: fix delta cache size accounting
The wrong value was substracted from delta_cache_size when replacing
a cached delta, as trg_entry->delta_size was used after the old size
had been replaced by the new size.
Noticed by Linus.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r-- | builtin-pack-objects.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 4f446588ac..350ece4d2a 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -1422,10 +1422,6 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, } } - trg_entry->delta = src_entry; - trg_entry->delta_size = delta_size; - trg->depth = src->depth + 1; - /* * Handle memory allocation outside of the cache * accounting lock. Compiler will optimize the strangeness @@ -1439,7 +1435,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, trg_entry->delta_data = NULL; } if (delta_cacheable(src_size, trg_size, delta_size)) { - delta_cache_size += trg_entry->delta_size; + delta_cache_size += delta_size; cache_unlock(); trg_entry->delta_data = xrealloc(delta_buf, delta_size); } else { @@ -1447,6 +1443,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, free(delta_buf); } + trg_entry->delta = src_entry; + trg_entry->delta_size = delta_size; + trg->depth = src->depth + 1; + return 1; } |