summaryrefslogtreecommitdiff
path: root/builtin-pack-objects.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2007-08-30 01:17:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-08-31 02:18:31 (GMT)
commit9e2d57a04ac42c7450e78668ee7037b35d56f7c3 (patch)
tree4698fc68b2c72968e8907cbdbbbb6f2e1178182a /builtin-pack-objects.c
parent55ced83d8aca98277c6a495932c57e6c3c45930b (diff)
downloadgit-9e2d57a04ac42c7450e78668ee7037b35d56f7c3.zip
git-9e2d57a04ac42c7450e78668ee7037b35d56f7c3.tar.gz
git-9e2d57a04ac42c7450e78668ee7037b35d56f7c3.tar.bz2
fix same sized delta logic
The code favoring shallower deltas when size is equal was triggered only when previous delta was also cached. There should be no relation between cached deltas and same sized deltas. 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.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 9b3ef94..12509fa 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1389,21 +1389,25 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
if (!delta_buf)
return 0;
- if (trg_entry->delta_data) {
+ if (trg_entry->delta) {
/* Prefer only shallower same-sized deltas. */
if (delta_size == trg_entry->delta_size &&
src->depth + 1 >= trg->depth) {
free(delta_buf);
return 0;
}
- delta_cache_size -= trg_entry->delta_size;
- free(trg_entry->delta_data);
- trg_entry->delta_data = NULL;
}
+
trg_entry->delta = src_entry;
trg_entry->delta_size = delta_size;
trg->depth = src->depth + 1;
+ if (trg_entry->delta_data) {
+ delta_cache_size -= trg_entry->delta_size;
+ free(trg_entry->delta_data);
+ trg_entry->delta_data = NULL;
+ }
+
if (delta_cacheable(src_size, trg_size, delta_size)) {
trg_entry->delta_data = xrealloc(delta_buf, delta_size);
delta_cache_size += trg_entry->delta_size;