]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-store: drop `loose_object_path()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 29 Apr 2025 07:52:16 +0000 (09:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Apr 2025 17:08:12 +0000 (10:08 -0700)
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>
http-walker.c
http.c
object-file.c
object-file.h
object-store.c
object-store.h

index 882cae19c2468c7b0224a57c66f7de0715ed5215..95458e2f6384bccb2b81d0e835dae91a6a357639 100644 (file)
@@ -9,6 +9,7 @@
 #include "list.h"
 #include "transport.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 struct alt_base {
@@ -540,7 +541,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)
                ret = error("File %s has bad hash", hex);
        } else if (req->rename < 0) {
                struct strbuf buf = STRBUF_INIT;
-               loose_object_path(the_repository, &buf, &req->oid);
+               odb_loose_path(the_repository->objects->odb, &buf, &req->oid);
                ret = error("unable to write sha1 filename %s", buf.buf);
                strbuf_release(&buf);
        }
diff --git a/http.c b/http.c
index 0c41138042562f445724126eb3d869aa49ee748b..3c029cf8947df7ca5a4997726a7f49fc4339c1aa 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
        oidcpy(&freq->oid, oid);
        freq->localfile = -1;
 
-       loose_object_path(the_repository, &filename, oid);
+       odb_loose_path(the_repository->objects->odb, &filename, oid);
        strbuf_addf(&freq->tmpfile, "%s.temp", filename.buf);
 
        strbuf_addf(&prevfile, "%s.prev", filename.buf);
@@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)
                unlink_or_warn(freq->tmpfile.buf);
                return -1;
        }
-       loose_object_path(the_repository, &filename, &freq->oid);
+       odb_loose_path(the_repository->objects->odb, &filename, &freq->oid);
        freq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);
        strbuf_release(&filename);
 
index 9cc3a24a40da1a5fc3bf2caf8b6729183afe1d5b..dc56a4766df4d1f05b40afd35c731410002ac417 100644 (file)
@@ -932,7 +932,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
        if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))
                prepare_loose_object_bulk_checkin();
 
-       loose_object_path(the_repository, &filename, oid);
+       odb_loose_path(the_repository->objects->odb, &filename, oid);
 
        fd = start_loose_object_common(&tmp_file, filename.buf, flags,
                                       &stream, compressed, sizeof(compressed),
@@ -1079,7 +1079,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,
                goto cleanup;
        }
 
-       loose_object_path(the_repository, &filename, oid);
+       odb_loose_path(the_repository->objects->odb, &filename, oid);
 
        /* We finally know the object path, and create the missing dir. */
        dirlen = directory_size(filename.buf);
index c002fbe23451b3ea7862aec0d6ae5af86c9094c7..0a7b6b9f9d928843173f9c1de986c19c79098b48 100644 (file)
@@ -25,6 +25,10 @@ int index_path(struct index_state *istate, struct object_id *oid, const char *pa
 
 struct object_directory;
 
+/*
+ * Put in `buf` the name of the file in the local object database that
+ * would be used to store a loose object with the specified oid.
+ */
 const char *odb_loose_path(struct object_directory *odb,
                           struct strbuf *buf,
                           const struct object_id *oid);
index 6ab50d25d3eb4f45af597cfb3aa896bdc91455c6..e5cfb8c007915ad55c9fde4ab4cf988cf9867a22 100644 (file)
@@ -96,12 +96,6 @@ int odb_pack_keep(const char *name)
        return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
 }
 
-const char *loose_object_path(struct repository *r, struct strbuf *buf,
-                             const struct object_id *oid)
-{
-       return odb_loose_path(r->objects->odb, buf, oid);
-}
-
 /*
  * Return non-zero iff the path is usable as an alternate object database.
  */
index e04469a85fba4a4216c694cdd58ddea82b9ad074..5668de62d01a5df8d4b5f84373e85c06e5f3bf51 100644 (file)
@@ -196,13 +196,6 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);
  */
 int odb_pack_keep(const char *name);
 
-/*
- * Put in `buf` the name of the file in the local object database that
- * would be used to store a loose object with the specified oid.
- */
-const char *loose_object_path(struct repository *r, struct strbuf *buf,
-                             const struct object_id *oid);
-
 void *map_loose_object(struct repository *r, const struct object_id *oid,
                       unsigned long *size);