pack-bitmap.c: break out of the bitmap loop early if not tracing

After opening a bitmap successfully, we try opening others only
because we want to report that other bitmap files are ignored in
the trace2 log.  When trace2 is not enabled, we do not have to
do any of that.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2022-11-28 22:09:52 +08:00 committed by Junio C Hamano
parent 8ddc06631b
commit 833f4c0514

View File

@ -527,8 +527,15 @@ static int open_pack_bitmap(struct repository *r,
assert(!bitmap_git->map);
for (p = get_all_packs(r); p; p = p->next) {
if (open_pack_bitmap_1(bitmap_git, p) == 0)
if (open_pack_bitmap_1(bitmap_git, p) == 0) {
ret = 0;
/*
* The only reason to keep looking is to report
* duplicates.
*/
if (!trace2_is_enabled())
break;
}
}
return ret;