Re: [PATCH v3 3/7] repo: add path.objects with absolute and relative suffix formatting
From: Justin Tobler <hidden>
Date: 2026-07-28 17:12:25
On 26/07/26 04:13PM, K Jayatheerth wrote:
Tools and deployment hooks frequently query the location of the object database directory. Currently, this relies on legacy parsing methods or manually inspecting `git rev-parse --git-path objects`.
"Tools and deployment hooks" seems a bit overly specific. Maybe instead we could just say "Scripts operating on a repository may need to query the location of the object database directory"? Also, I'm not entirely sure what is meant by "legacy parsing methods" here.
Introduce `path.objects.absolute` and `path.objects.relative` keys to `git repo info`. This allows tools to discover the object database location safely while natively adhering to active `GIT_OBJECT_DIRECTORY` environment variable overrides.
In the context of pluggable ODBs, this proposed key is a little more interesting because a non-"files" ODB source in the future may not even have a filesystem path to an objects directory. When this becomes more relevant, we could just adapt these keys to return an empty string in such cases, but it does also make me question whether it is information that we should further expose in the first place if it does eventually becomes an internal detail of a specific ODB source. It probably doesn't matter too much, but I've CC'd Patrick for his thoughts too. [snip]
quoted hunk ↗ jump to hunk
diff --git a/builtin/repo.c b/builtin/repo.c index 82359473e9..d6bdd5bcfa 100644 --- a/builtin/repo.c +++ b/builtin/repo.c@@ -122,6 +122,28 @@ static int get_path_gitdir_relative(struct repository *repo, struct strbuf *buf) return 0; } +static int get_path_objects_absolute(struct repository *repo, struct strbuf *buf) +{ + const char *obj_dir = repo_get_object_directory(repo); + + if (!obj_dir) + return error(_("unable to get object directory")); + + format_path(buf, obj_dir, startup_info->prefix, PATH_FORMAT_CANONICAL);
For the absolute path, do we actually need to provide the prefix? It might make it more clear that its the aboslute path if we just pass "" instead? -Justin