mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-27 13:21:17 -05:00
pack-objects: extract record_tree_depth() helper
Prepare for a subsequent change that needs to record tree depths from a second call site by factoring the delta-islands tree-depth bookkeeping out of `show_object()` and into a helper, `record_tree_depth()`. The helper looks up the object in `to_pack`, returns early when the object was not added there, computes the depth from the slash count in the supplied name, and preserves the existing max-depth-wins behavior when a tree is reached by more than one path. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
0a37451106
commit
264efee401
@@ -2730,6 +2730,22 @@ static inline void oe_set_tree_depth(struct packing_data *pack,
|
||||
pack->tree_depth[e - pack->objects] = tree_depth;
|
||||
}
|
||||
|
||||
static void record_tree_depth(const struct object_id *oid, const char *name)
|
||||
{
|
||||
const char *p;
|
||||
unsigned depth;
|
||||
struct object_entry *ent;
|
||||
|
||||
/* the empty string is a root tree, which is depth 0 */
|
||||
depth = *name ? 1 : 0;
|
||||
for (p = strchr(name, '/'); p; p = strchr(p + 1, '/'))
|
||||
depth++;
|
||||
|
||||
ent = packlist_find(&to_pack, oid);
|
||||
if (ent && depth > oe_tree_depth(&to_pack, ent))
|
||||
oe_set_tree_depth(&to_pack, ent, depth);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the size of the object without doing any delta
|
||||
* reconstruction (so non-deltas are true object sizes, but deltas
|
||||
@@ -4385,20 +4401,8 @@ static void show_object(struct object *obj, const char *name,
|
||||
add_preferred_base_object(name);
|
||||
add_object_entry(&obj->oid, obj->type, name, 0);
|
||||
|
||||
if (use_delta_islands) {
|
||||
const char *p;
|
||||
unsigned depth;
|
||||
struct object_entry *ent;
|
||||
|
||||
/* the empty string is a root tree, which is depth 0 */
|
||||
depth = *name ? 1 : 0;
|
||||
for (p = strchr(name, '/'); p; p = strchr(p + 1, '/'))
|
||||
depth++;
|
||||
|
||||
ent = packlist_find(&to_pack, &obj->oid);
|
||||
if (ent && depth > oe_tree_depth(&to_pack, ent))
|
||||
oe_set_tree_depth(&to_pack, ent, depth);
|
||||
}
|
||||
if (use_delta_islands)
|
||||
record_tree_depth(&obj->oid, name);
|
||||
}
|
||||
|
||||
static void show_object__ma_allow_any(struct object *obj, const char *name, void *data)
|
||||
|
||||
Reference in New Issue
Block a user