git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 02/13] object-store: drop `loose_object_path()`

From
Patrick Steinhardt <ps@pks.im>
Date
Apr 23, 2025, 07:48 UTC
Message-ID
<20250423-pks-object-store-cleanups-v1-2-81f8411a5d08@pks.im>
In-Reply-To
<20250423-pks-object-store-cleanups-v1-0-81f8411a5d08@pks.im>

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>
---
 http-walker.c  | 3 ++-
 http.c         | 4 ++--
 object-file.c  | 4 ++--
 object-file.h  | 4 ++++
 object-store.c | 6 ------
 object-store.h | 7 -------
 6 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/http-walker.c b/http-walker.c
index 882cae19c24..95458e2f638 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -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 0c411380425..3c029cf8947 100644
--- 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);
 
diff --git a/object-file.c b/object-file.c
index 9cc3a24a40d..dc56a4766df 100644
--- a/object-file.c
+++ b/object-file.c
@@ -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);
diff --git a/object-file.h b/object-file.h
index c002fbe2345..0a7b6b9f9d9 100644
--- a/object-file.h
+++ b/object-file.h
@@ -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);
diff --git a/object-store.c b/object-store.c
index 6ab50d25d3e..e5cfb8c0079 100644
--- a/object-store.c
+++ b/object-store.c
@@ -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.
  */
diff --git a/object-store.h b/object-store.h
index e04469a85fb..5668de62d01 100644
--- a/object-store.h
+++ b/object-store.h
@@ -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);
 
-- 
2.49.0.901.g37484f566f.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 55 in “object-store: a handful of cleanups”
  1. 00/13 object-store: a handful of cleanupsPatrick Steinhardt, Apr 23, 2025
  2. 01/13 object-store: move `struct packed_git` into "packfile.h"Patrick Steinhardt, Apr 23, 2025
  3. 02/13 object-store: drop `loose_object_path()`Patrick Steinhardt, Apr 23, 2025
  4. 03/13 object-store: move and rename `odb_pack_keep()`Patrick Steinhardt, Apr 23, 2025
  5. Karthik NayakApr 23, 2025
  6. 05/13 object-store: allow fetching objects via `has_object()`Patrick Steinhardt, Apr 23, 2025
  7. Karthik NayakApr 23, 2025
  8. 04/13 object-store: move function declarations to their respective subsystemsPatrick Steinhardt, Apr 23, 2025
  9. 06/13 treewide: trivial conversions of `repo_has_object_file()`Patrick Steinhardt, Apr 23, 2025
  10. 07/13 builtin/index-pack: don't fetch promised objects for collision checkPatrick Steinhardt, Apr 23, 2025
  11. Karthik NayakApr 23, 2025
  12. Patrick SteinhardtApr 25, 2025
  13. Karthik NayakApr 28, 2025
  14. 08/13 builtin/show-ref: don't fetch objects when printing refsPatrick Steinhardt, Apr 23, 2025
  15. 09/13 refs: don't fetch promisor objects in `ref_resolves_to_object()`Patrick Steinhardt, Apr 23, 2025
  16. Karthik NayakApr 23, 2025
  17. 10/13 http-walker: don't fetch objects via promisor remotesPatrick Steinhardt, Apr 23, 2025
  18. 11/13 list-objects: clarify how promised blobs are excludedPatrick Steinhardt, Apr 23, 2025
  19. 12/13 bulk-checkin: don't fetch promised objects on writePatrick Steinhardt, Apr 23, 2025
  20. 13/13 object-store: drop `repo_has_object_file()`Patrick Steinhardt, Apr 23, 2025
  21. Karthik NayakApr 23, 2025
  22. Patrick SteinhardtApr 25, 2025
  23. 00/13 object-store: a handful of cleanupsPatrick Steinhardt, Apr 25, 2025
  24. 01/13 object-store: move `struct packed_git` into "packfile.h"Patrick Steinhardt, Apr 25, 2025
  25. 02/13 object-store: drop `loose_object_path()`Patrick Steinhardt, Apr 25, 2025
  26. 03/13 object-store: move and rename `odb_pack_keep()`Patrick Steinhardt, Apr 25, 2025
  27. 04/13 object-store: move function declarations to their respective subsystemsPatrick Steinhardt, Apr 25, 2025
  28. 05/13 object-store: allow fetching objects via `has_object()`Patrick Steinhardt, Apr 25, 2025
  29. 06/13 treewide: trivial conversions of `repo_has_object_file()`Patrick Steinhardt, Apr 25, 2025
  30. Junio C HamanoApr 28, 2025
  31. 07/13 builtin/index-pack: don't fetch promised objects for collision checkPatrick Steinhardt, Apr 25, 2025
  32. Junio C HamanoApr 28, 2025
  33. Patrick SteinhardtApr 29, 2025
  34. 08/13 builtin/show-ref: don't fetch objects when printing refsPatrick Steinhardt, Apr 25, 2025
  35. Junio C HamanoApr 28, 2025
  36. 09/13 refs: don't fetch promisor objects in `ref_resolves_to_object()`Patrick Steinhardt, Apr 25, 2025
  37. Junio C HamanoApr 28, 2025
  38. 10/13 http-walker: don't fetch objects via promisor remotesPatrick Steinhardt, Apr 25, 2025
  39. Junio C HamanoApr 28, 2025
  40. 11/13 list-objects: clarify how promised blobs are excludedPatrick Steinhardt, Apr 25, 2025
  41. 12/13 bulk-checkin: don't fetch promised objects on writePatrick Steinhardt, Apr 25, 2025
  42. Junio C HamanoApr 28, 2025
  43. Patrick SteinhardtApr 29, 2025
  44. Junio C HamanoApr 29, 2025
  45. 13/13 object-store: drop `repo_has_object_file()`Patrick Steinhardt, Apr 25, 2025
  46. Karthik NayakApr 28, 2025
  47. 0/7 object-store: a handful of cleanupsPatrick Steinhardt, Apr 29, 2025
  48. 1/7 object-store: move `struct packed_git` into "packfile.h"Patrick Steinhardt, Apr 29, 2025
  49. 2/7 object-store: drop `loose_object_path()`Patrick Steinhardt, Apr 29, 2025
  50. 3/7 object-store: move and rename `odb_pack_keep()`Patrick Steinhardt, Apr 29, 2025
  51. 4/7 object-store: move function declarations to their respective subsystemsPatrick Steinhardt, Apr 29, 2025
  52. 5/7 object-store: allow fetching objects via `has_object()`Patrick Steinhardt, Apr 29, 2025
  53. 6/7 treewide: convert users of `repo_has_object_file()` to `has_object()`Patrick Steinhardt, Apr 29, 2025
  54. 7/7 object-store: drop `repo_has_object_file()`Patrick Steinhardt, Apr 29, 2025
  55. Junio C HamanoApr 29, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.