summary refs log tree commit diff
path: root/pack-objects.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-09-17 13:53:55 -0700
committerJunio C Hamano <gitster@pobox.com>2018-09-17 13:53:55 -0700
commitf3504ea3dd21b0a6d38bcd369efa0663cdc05416 (patch)
treec8eb1191474dc37e25f082917e803915525c15d1 /pack-objects.h
parentfba9654364a523bf146df26052ab05dd52c1d719 (diff)
parentfe0ac2fb7f8e87d37ef83dcee2d93901d58d8277 (diff)
Merge branch 'cc/delta-islands'
Lift code from GitHub to restrict delta computation so that an
object that exists in one fork is not made into a delta against
another object that does not appear in the same forked repository.

* cc/delta-islands:
  pack-objects: move 'layer' into 'struct packing_data'
  pack-objects: move tree_depth into 'struct packing_data'
  t5320: tests for delta islands
  repack: add delta-islands support
  pack-objects: add delta-islands support
  pack-objects: refactor code into compute_layer_order()
  Add delta-islands.{c,h}
Diffstat (limited to 'pack-objects.h')
-rw-r--r--pack-objects.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/pack-objects.h b/pack-objects.h
index b0c1f137c6..2ca39cfcfe 100644
--- a/pack-objects.h
+++ b/pack-objects.h
@@ -103,6 +103,7 @@ struct object_entry {
 	unsigned no_try_delta:1;
 	unsigned type_:TYPE_BITS;
 	unsigned in_pack_type:TYPE_BITS; /* could be delta */
+
 	unsigned preferred_base:1; /*
 				    * we do not pack this, but is available
 				    * to be used as the base object to delta
@@ -158,6 +159,10 @@ struct packing_data {
 
 	uintmax_t oe_size_limit;
 	uintmax_t oe_delta_size_limit;
+
+	/* delta islands */
+	unsigned int *tree_depth;
+	unsigned char *layer;
 };
 
 void prepare_packing_data(struct packing_data *pdata);
@@ -400,4 +405,38 @@ static inline void oe_set_delta_size(struct packing_data *pack,
 	}
 }
 
+static inline unsigned int oe_tree_depth(struct packing_data *pack,
+					 struct object_entry *e)
+{
+	if (!pack->tree_depth)
+		return 0;
+	return pack->tree_depth[e - pack->objects];
+}
+
+static inline void oe_set_tree_depth(struct packing_data *pack,
+				     struct object_entry *e,
+				     unsigned int tree_depth)
+{
+	if (!pack->tree_depth)
+		ALLOC_ARRAY(pack->tree_depth, pack->nr_objects);
+	pack->tree_depth[e - pack->objects] = tree_depth;
+}
+
+static inline unsigned char oe_layer(struct packing_data *pack,
+				     struct object_entry *e)
+{
+	if (!pack->layer)
+		return 0;
+	return pack->layer[e - pack->objects];
+}
+
+static inline void oe_set_layer(struct packing_data *pack,
+				struct object_entry *e,
+				unsigned char layer)
+{
+	if (!pack->layer)
+		ALLOC_ARRAY(pack->layer, pack->nr_objects);
+	pack->layer[e - pack->objects] = layer;
+}
+
 #endif