summaryrefslogtreecommitdiffstats
path: root/tmp-objdir.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-09-12 13:29:30 +0200
committerJunio C Hamano <gitster@pobox.com>2024-09-12 19:15:39 +0200
commita3673f48986cf990006e56a57e4ad3c7134161e7 (patch)
treee851e1882c9ab652b45e416dc2b4196ed0f09ac0 /tmp-objdir.c
parentenvironment: make `get_git_common_dir()` accept a repository (diff)
downloadgit-a3673f48986cf990006e56a57e4ad3c7134161e7.tar.xz
git-a3673f48986cf990006e56a57e4ad3c7134161e7.zip
environment: make `get_object_directory()` accept a repository
The `get_object_directory()` function retrieves the path to the object directory for `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tmp-objdir.c')
-rw-r--r--tmp-objdir.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tmp-objdir.c b/tmp-objdir.c
index a8e4553f27..c2fb9f9193 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -13,6 +13,7 @@
#include "strvec.h"
#include "quote.h"
#include "object-store-ll.h"
+#include "repository.h"
struct tmp_objdir {
struct strbuf path;
@@ -132,7 +133,8 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix)
* can recognize any stale objdirs left behind by a crash and delete
* them.
*/
- strbuf_addf(&t->path, "%s/tmp_objdir-%s-XXXXXX", get_object_directory(), prefix);
+ strbuf_addf(&t->path, "%s/tmp_objdir-%s-XXXXXX",
+ repo_get_object_directory(the_repository), prefix);
if (!mkdtemp(t->path.buf)) {
/* free, not destroy, as we never touched the filesystem */
@@ -152,7 +154,7 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix)
}
env_append(&t->env, ALTERNATE_DB_ENVIRONMENT,
- absolute_path(get_object_directory()));
+ absolute_path(repo_get_object_directory(the_repository)));
env_replace(&t->env, DB_ENVIRONMENT, absolute_path(t->path.buf));
env_replace(&t->env, GIT_QUARANTINE_ENVIRONMENT,
absolute_path(t->path.buf));
@@ -267,7 +269,7 @@ int tmp_objdir_migrate(struct tmp_objdir *t)
}
strbuf_addbuf(&src, &t->path);
- strbuf_addstr(&dst, get_object_directory());
+ strbuf_addstr(&dst, repo_get_object_directory(the_repository));
ret = migrate_paths(&src, &dst);