]> git.99rst.org Git - git.git/commit
pack-bitmap: allow aborting iteration of bitmapped objects
authorPatrick Steinhardt <redacted>
Wed, 15 Jul 2026 06:22:34 +0000 (08:22 +0200)
committerJunio C Hamano <redacted>
Wed, 15 Jul 2026 14:19:16 +0000 (07:19 -0700)
commit1ca65ca7b8bce87268900e39315888fd10fc350c
tree41795bbd398e711486c0e8271e0d890a8c73b0c9
parent6f48b8ce56171419f768902b300365c1b6708c96
pack-bitmap: allow aborting iteration of bitmapped objects

In a subsequent commit we'll lift iteration of bitmapped objects into
the "packed" backend and make it accessible via `odb_for_each_object()`.
The calling convention for that function is that the callback may return
a non-zero exit code, and if so we'll abort iteration. This is currently
impossible to realize though, as `for_each_bitmapped_object()` will
ignore any return value and just churn through all objects completely.

This doesn't matter to the callers of `for_each_bitmapped_object()`, as
there's only one of them in git-cat-file(1), and the callbacks we pass
always return zero. But once we move the logic into the generic
infrastructure it becomes a latent bug waiting to happen.

Refactor the code so that the return value of the `show_reach` callback
is not ignored anymore. Instead, returning a non-zero value will cause
us to abort iteration in both `show_objects_for_type()` and in
`for_each_bitmapped_object()`.

Note though that there's a second user of `show_objects_for_type()` with
`traverse_bitmap_commit_list()`, and that function does indeed invoke
callbacks that may return non-zero. This non-zero return value never had
any effect at all though, and the callbacks that return non-zero values
are only ever invoked via `traverse_bitmap_commit_list()`. Consequently,
we adapt them to always return 0.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/pack-objects.c
builtin/rev-list.c
pack-bitmap.c
pack-bitmap.h
git clone https://git.99rst.org/PROJECT