pack-objects: fix tree_depth and layer invariants
[gitweb.git] / pack-objects.h
index edf74dabddfdb2b67bad803d1c898e93a3af4d8b..741e6f862dee5768290d0360bc4a67b774c0a044 100644 (file)
@@ -100,6 +100,7 @@ struct object_entry {
        unsigned type_:TYPE_BITS;
        unsigned no_try_delta:1;
        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
@@ -141,6 +142,10 @@ struct packing_data {
        struct packed_git **in_pack;
 
        uintmax_t oe_size_limit;
+
+       /* delta islands */
+       unsigned int *tree_depth;
+       unsigned char *layer;
 };
 
 void prepare_packing_data(struct packing_data *pdata);
@@ -346,4 +351,38 @@ static inline void oe_set_delta_size(struct packing_data *pack,
                    "where delta size is the same as entry size");
 }
 
+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_alloc);
+       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_alloc);
+       pack->layer[e - pack->objects] = layer;
+}
+
 #endif