Thread (175 messages) 175 messages, 5 authors, 2024-12-03

Re: [PATCH v7 6/9] packfile: pass down repository to `for_each_packed_object`

From: Taylor Blau <hidden>
Date: 2024-11-20 22:38:46

On Mon, Nov 11, 2024 at 12:14:06PM +0100, Karthik Nayak wrote:
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help