summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-03-26 03:23:38 -0400
committerJunio C Hamano <gitster@pobox.com>2014-03-28 11:02:16 -0700
commit6d3c7696d0a6460dbb125d6ca9327640e4296b44 (patch)
tree71b93f1d053e25f3d832653b68fc8bdad0c91b1e
parentb4f56ffb3785090e0a122cbc98b12c2e330a8eac (diff)
downloadgit-jk/pack-bitmap-reuse-deltas.tar.gz
pack-objects: reuse deltas for thin "have" objectsjk/pack-bitmap-reuse-deltas
When we calculate the "wants" and "haves" for a pack, we only add the objects in the boundary commits as preferred bases. However, we know that every object reachable from the "haves" could be a preferred base. We probably don't want to add these to our preferred base list, because they would clog the delta-search window. However, there is no reason we cannot reuse an on-disk delta against such a deep "have" base, avoiding the delta search for that object altogether. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/pack-objects.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 0ee5f1ff94..acbf957036 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -53,6 +53,7 @@ static unsigned long pack_size_limit;
static int depth = 50;
static int delta_search_threads;
static int pack_to_stdout;
+static int thin = 0;
static int num_preferred_base;
static struct progress *progress_state;
static int pack_compression_level = Z_DEFAULT_COMPRESSION;
@@ -1396,6 +1397,20 @@ static void check_object(struct object_entry *entry)
base_entry->delta_child = entry;
unuse_pack(&w_curs);
return;
+ } else if (thin && base_ref && bitmap_have(base_ref)) {
+ entry->type = entry->in_pack_type;
+ entry->delta_size = entry->size;
+ /*
+ * XXX we'll leak this, but it's probably OK
+ * since we'll exit immediately after the packing
+ * is done
+ */
+ entry->delta = xcalloc(1, sizeof(*entry->delta));
+ hashcpy(entry->delta->idx.sha1, base_ref);
+ entry->delta->preferred_base = 1;
+ entry->delta->filled = 1;
+ unuse_pack(&w_curs);
+ return;
}
if (entry->type) {
@@ -2541,7 +2556,6 @@ static int option_parse_ulong(const struct option *opt,
int cmd_pack_objects(int argc, const char **argv, const char *prefix)
{
int use_internal_rev_list = 0;
- int thin = 0;
int all_progress_implied = 0;
const char *rp_av[6];
int rp_ac = 0;