summaryrefslogtreecommitdiff
path: root/builtin-pack-objects.c
diff options
context:
space:
mode:
authorBrian Downing <bdowning@lavos.net>2007-07-09 04:45:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-07-09 06:48:17 (GMT)
commit848d732c10616269886d0b9c82e434b65ffc33f0 (patch)
tree8b870e4121957b3c81be9d8beb86593e2e7fe672 /builtin-pack-objects.c
parent1ed84157a21a3e868228b15588e4aadfbe5a030b (diff)
downloadgit-848d732c10616269886d0b9c82e434b65ffc33f0.zip
git-848d732c10616269886d0b9c82e434b65ffc33f0.tar.gz
git-848d732c10616269886d0b9c82e434b65ffc33f0.tar.bz2
pack-objects: Prefer shallower deltas if the size is equal
Change "try_delta" so that if it finds a delta that has the same size but shallower depth than the existing delta, it will prefer the shallower one. This makes certain delta trees vastly less deep. Signed-off-by: Brian Downing <bdowning@lavos.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r--builtin-pack-objects.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 3d396ca..54b9d26 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1337,7 +1337,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
if (max_size == 0)
return 0;
if (trg_entry->delta && trg_entry->delta_size <= max_size)
- max_size = trg_entry->delta_size-1;
+ max_size = trg_entry->delta_size;
src_size = src_entry->size;
sizediff = src_size < trg_size ? trg_size - src_size : 0;
if (sizediff >= max_size)
@@ -1371,6 +1371,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
return 0;
if (trg_entry->delta_data) {
+ /* Prefer only shallower same-sized deltas. */
+ if (delta_size == trg_entry->delta_size &&
+ src_entry->depth + 1 >= trg_entry->depth) {
+ free(delta_buf);
+ return 0;
+ }
delta_cache_size -= trg_entry->delta_size;
free(trg_entry->delta_data);
}