mirror of
https://github.com/git/git
synced 2024-10-12 11:32:34 +00:00
Merge branch 'jv/pack-objects-narrower-ref-iteration'
The "pack-objects" command needs to iterate over all the tags when automatic tag following is enabled, but it actually iterated over all refs and then discarded everything outside "refs/tags/" hierarchy, which was quite wasteful. * jv/pack-objects-narrower-ref-iteration: builtin/pack-objects.c: avoid iterating all refs
This commit is contained in:
commit
77db59c2f9
|
@ -2814,13 +2814,11 @@ static void add_tag_chain(const struct object_id *oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_ref_tag(const char *path, const struct object_id *oid, int flag, void *cb_data)
|
static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)
|
||||||
{
|
{
|
||||||
struct object_id peeled;
|
struct object_id peeled;
|
||||||
|
|
||||||
if (starts_with(path, "refs/tags/") && /* is a tag? */
|
if (!peel_iterated_oid(oid, &peeled) && obj_is_packed(&peeled))
|
||||||
!peel_iterated_oid(oid, &peeled) && /* peelable? */
|
|
||||||
obj_is_packed(&peeled)) /* object packed? */
|
|
||||||
add_tag_chain(oid);
|
add_tag_chain(oid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3751,7 +3749,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
|
||||||
}
|
}
|
||||||
cleanup_preferred_base();
|
cleanup_preferred_base();
|
||||||
if (include_tag && nr_result)
|
if (include_tag && nr_result)
|
||||||
for_each_ref(add_ref_tag, NULL);
|
for_each_tag_ref(add_ref_tag, NULL);
|
||||||
stop_progress(&progress_state);
|
stop_progress(&progress_state);
|
||||||
trace2_region_leave("pack-objects", "enumerate-objects",
|
trace2_region_leave("pack-objects", "enumerate-objects",
|
||||||
the_repository);
|
the_repository);
|
||||||
|
|
Loading…
Reference in a new issue