object-store: drop `loose_object_path()`

The function `loose_object_path()` is a trivial wrapper around `odb_loose_path()`, with the only exception that it always uses the primary object database of the given repository. This doesn't really add a ton of value though, so let's drop the function and inline it at every callsite. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Apr 29, 2025 at 09:52 UTC 56ef85e82ffa39ac86db39bc0ac11c67451d0e5b
6 files changed +10 -18
http-walker.c
+2 -1
@@ -9,6 +9,7 @@
9 #include "list.h"
10 #include "transport.h"
11 #include "packfile.h"
12 +#include "object-file.h"
13 #include "object-store.h"
14
15 struct alt_base {
@@ -540,7 +541,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)
541 ret = error("File %s has bad hash", hex);
542 } else if (req->rename < 0) {
543 struct strbuf buf = STRBUF_INIT;
543 - loose_object_path(the_repository, &buf, &req->oid);
544 + odb_loose_path(the_repository->objects->odb, &buf, &req->oid);
545 ret = error("unable to write sha1 filename %s", buf.buf);
546 strbuf_release(&buf);
547 }
http.c
+2 -2
@@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
2662 oidcpy(&freq->oid, oid);
2663 freq->localfile = -1;
2664
2665 - loose_object_path(the_repository, &filename, oid);
2665 + odb_loose_path(the_repository->objects->odb, &filename, oid);
2666 strbuf_addf(&freq->tmpfile, "%s.temp", filename.buf);
2667
2668 strbuf_addf(&prevfile, "%s.prev", filename.buf);
@@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)
2814 unlink_or_warn(freq->tmpfile.buf);
2815 return -1;
2816 }
2817 - loose_object_path(the_repository, &filename, &freq->oid);
2817 + odb_loose_path(the_repository->objects->odb, &filename, &freq->oid);
2818 freq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);
2819 strbuf_release(&filename);
2820
object-file.c
+2 -2
@@ -932,7 +932,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
932 if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))
933 prepare_loose_object_bulk_checkin();
934
935 - loose_object_path(the_repository, &filename, oid);
935 + odb_loose_path(the_repository->objects->odb, &filename, oid);
936
937 fd = start_loose_object_common(&tmp_file, filename.buf, flags,
938 &stream, compressed, sizeof(compressed),
@@ -1079,7 +1079,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,
1079 goto cleanup;
1080 }
1081
1082 - loose_object_path(the_repository, &filename, oid);
1082 + odb_loose_path(the_repository->objects->odb, &filename, oid);
1083
1084 /* We finally know the object path, and create the missing dir. */
1085 dirlen = directory_size(filename.buf);
object-file.h
+4
@@ -25,6 +25,10 @@ int index_path(struct index_state *istate, struct object_id *oid, const char *pa
25
26 struct object_directory;
27
28 +/*
29 + * Put in `buf` the name of the file in the local object database that
30 + * would be used to store a loose object with the specified oid.
31 + */
32 const char *odb_loose_path(struct object_directory *odb,
33 struct strbuf *buf,
34 const struct object_id *oid);
object-store.c
-6
@@ -96,12 +96,6 @@ int odb_pack_keep(const char *name)
96 return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
97 }
98
99 -const char *loose_object_path(struct repository *r, struct strbuf *buf,
100 - const struct object_id *oid)
101 -{
102 - return odb_loose_path(r->objects->odb, buf, oid);
103 -}
104 -
99 /*
100 * Return non-zero iff the path is usable as an alternate object database.
101 */
object-store.h
-7
@@ -196,13 +196,6 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);
196 */
197 int odb_pack_keep(const char *name);
198
199 -/*
200 - * Put in `buf` the name of the file in the local object database that
201 - * would be used to store a loose object with the specified oid.
202 - */
203 -const char *loose_object_path(struct repository *r, struct strbuf *buf,
204 - const struct object_id *oid);
205 -
199 void *map_loose_object(struct repository *r, const struct object_id *oid,
200 unsigned long *size);
201