Re: [PATCH v7 6/9] packfile: pass down repository to `for_each_packed_object`
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Nov 20, 2024, 22:38 UTC
- Message-ID
- <Zz5k9HsezqHEWTEm@nand.local>
- In-Reply-To
- <1b26e45a9b4952da03ad0e2fbc0fa22bc1f5b447.1731323350.git.karthik.188@gmail.com>
On Mon, Nov 11, 2024 at 12:14:06PM +0100, Karthik Nayak wrote:
Show 24 quoted lines
> diff --git a/packfile.c b/packfile.c
> index e7dd270217..5e8019b1fe 100644
> --- a/packfile.c
> +++ b/packfile.c
> @@ -2200,15 +2200,15 @@ int for_each_object_in_pack(struct packed_git *p,
> return r;
> }
>
> -int for_each_packed_object(each_packed_object_fn cb, void *data,
> - enum for_each_object_flags flags)
> +int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
> + void *data, enum for_each_object_flags flags)
> {
> struct packed_git *p;
> int r = 0;
> int pack_errors = 0;
>
> - prepare_packed_git(the_repository);
> - for (p = get_all_packs(the_repository); p; p = p->next) {
> + prepare_packed_git(repo);
> + for (p = get_all_packs(repo); p; p = p->next) {
> if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
> continue;
> if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&Not the fault of your series, but this prepare_packed_git() call is unnecessary, since it is the first thing that get_all_packs() does when it executes.
I suspect that this call comes from way back in 660c889e46 (sha1_file: add for_each iterators for loose and packed objects, 2014-10-15). It could have been removed in 454ea2e4d7 (treewide: use get_all_packs, 2018-08-20), but I think that patch was a straightforward conversion that did not inspect each individual change.
Anyway, nothing to do immediately here, but just something I saw when reviewing and figured was worth writing down somewhere.
Thanks, Taylor