Skip to content

Commit 77db59c

Browse files
committed
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
2 parents f6ef8ba + be18153 commit 77db59c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

builtin/pack-objects.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,13 +2814,11 @@ static void add_tag_chain(const struct object_id *oid)
28142814
}
28152815
}
28162816

2817-
static int add_ref_tag(const char *path, const struct object_id *oid, int flag, void *cb_data)
2817+
static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)
28182818
{
28192819
struct object_id peeled;
28202820

2821-
if (starts_with(path, "refs/tags/") && /* is a tag? */
2822-
!peel_iterated_oid(oid, &peeled) && /* peelable? */
2823-
obj_is_packed(&peeled)) /* object packed? */
2821+
if (!peel_iterated_oid(oid, &peeled) && obj_is_packed(&peeled))
28242822
add_tag_chain(oid);
28252823
return 0;
28262824
}
@@ -3751,7 +3749,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
37513749
}
37523750
cleanup_preferred_base();
37533751
if (include_tag && nr_result)
3754-
for_each_ref(add_ref_tag, NULL);
3752+
for_each_tag_ref(add_ref_tag, NULL);
37553753
stop_progress(&progress_state);
37563754
trace2_region_leave("pack-objects", "enumerate-objects",
37573755
the_repository);

0 commit comments

Comments
 (0)