Re: [PATCH v2 3/4] loose: lift loose object index writing logic into helper

From
Patrick Steinhardt <hidden>
Date
2026-10-29 08:05:56
Reply to
Justin Tobler, 2026-10-29
On Wed, Oct 28, 2026 at 07:24:12PM -0500, Justin Tobler wrote:
Writing the in-memory loose object map to a "loose-object-idx" file is
handled via `repo_write_loose_object_map()`, which always writes the map
into the primary object directory. In a subsequent commit, a separate
"loose-object-idx" file is staged prior to commit and must be
constructed from a loose object map not attached to the primary loose
object source.

Extract the logic for writing a loose object index file into a separate
`loose_object_map_write()` helper function that allows callers to
explicitly specify both the loose object map as well as the file
descriptor to write the entries to.
Okay. This commit is essentially the equivalent to the preceding one,
but for writes.
quoted hunk ↗ jump to hunk
diff --git a/loose.c b/loose.c
index 5f72c644f9..f2e111c25e 100644
--- a/loose.c
+++ b/loose.c
@@ -146,25 +146,17 @@ int repo_read_loose_object_map(struct repository *repo)
 	return 0;
 }
 
-int repo_write_loose_object_map(struct repository *repo)
+static int loose_object_map_write(struct repository *repo,
+				  struct loose_object_map *loose_map, int fd)
Curious that you're using a file descriptor instead of a path as you did
in the preceding commit. But I guess that's because of how we first have
to lock the file, which we of course don't have to do on the writing
side.

I guess we could've also moved locking into this function here to make
both interfaces match, but maybe the next commit will give a hint why we
don't.

Patrick
Thread (34 messages) 34 messages, 4 authors, last reply 2d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help