Signed-off-by: Teng Long <dyroneteng@xxxxxxxxx> --- builtin/pack-objects.c | 52 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index d5e3f2c229..503f8a5746 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1206,6 +1206,21 @@ static int match_packfile_uri_exclusions(struct configured_exclusion *ex) return 0; } +static int want_exclude_object(struct object_list *objects) +{ + struct object_list *p; + struct configured_exclusion *ex; + + if (!objects) + return 0; + for (p = objects; p; p = p->next) { + ex = oidmap_get(&configured_exclusions, &p->item->oid); + if (match_packfile_uri_exclusions(ex)) + return 1; + } + return 0; +} + static int want_found_object(const struct object_id *oid, int exclude, struct packed_git *p) { @@ -1317,11 +1332,8 @@ static int want_object_in_pack(const struct object_id *oid, int want; struct list_head *pos; struct multi_pack_index *m; - struct configured_exclusion *tag_ex; struct configured_exclusion *commit_ex; - struct configured_exclusion *tree_ex; struct configured_exclusion *ex; - struct object_list *p; if (!exclude && local && has_loose_object_nonlocal(oid)) return 0; @@ -1357,41 +1369,27 @@ static int want_object_in_pack(const struct object_id *oid, } if (uri_protocols.nr) { - if (referred_objs && referred_objs->tags) { - for (p = referred_objs->tags; p; p = p->next) { - tag_ex = oidmap_get(&configured_exclusions, &p->item->oid); - if (match_packfile_uri_exclusions(tag_ex)) + if (referred_objs) { + if (referred_objs->commit) { + struct commit *commit = (struct commit *) referred_objs->commit; + commit_ex = oidmap_get(&configured_exclusions, &commit->object.oid); + if (match_packfile_uri_exclusions(commit_ex)) return 0; - } - } - - if (referred_objs && referred_objs->commit) { - commit_ex = oidmap_get(&configured_exclusions, &referred_objs->commit->oid); - if (match_packfile_uri_exclusions(commit_ex)) - return 0; - struct commit *commit = (struct commit*) referred_objs->commit; - for (p = commit->wraps; p; p = p->next) { - tag_ex = oidmap_get(&configured_exclusions, &p->item->oid); - if (match_packfile_uri_exclusions(tag_ex)) + if (want_exclude_object(commit->wraps)) return 0; } - } + if (referred_objs->tags && want_exclude_object(referred_objs->tags)) + return 0; - if (referred_objs && referred_objs->trees) { - for (p = referred_objs->trees; p; p = p->next) { - tree_ex = oidmap_get(&configured_exclusions, &p->item->oid); - if (match_packfile_uri_exclusions(tree_ex)) - return 0; - } + if (referred_objs->trees && want_exclude_object(referred_objs->trees)) + return 0; } - ex = oidmap_get(&configured_exclusions, oid); if (match_packfile_uri_exclusions(ex)) { oidset_insert(&excluded_by_config, oid); return 0; } } - return 1; } -- 2.31.1.456.gec51e24953