* into the alternative object store list as the primary.
*/
if (opt->remerge_diff && !opt->remerge_objdir) {
- opt->remerge_objdir = tmp_objdir_create("remerge-diff");
+ opt->remerge_objdir = tmp_objdir_create(the_repository, "remerge-diff");
if (!opt->remerge_objdir)
return error(_("unable to create temporary object directory"));
tmp_objdir_replace_primary_odb(opt->remerge_objdir, 1);
-#define USE_THE_REPOSITORY_VARIABLE
-
#include "git-compat-util.h"
#include "tmp-objdir.h"
#include "abspath.h"
#include "repository.h"
struct tmp_objdir {
+ struct repository *repo;
struct strbuf path;
struct strvec env;
struct object_directory *prev_odb;
return ret;
}
-struct tmp_objdir *tmp_objdir_create(const char *prefix)
+struct tmp_objdir *tmp_objdir_create(struct repository *r,
+ const char *prefix)
{
static int installed_handlers;
struct tmp_objdir *t;
BUG("only one tmp_objdir can be used at a time");
t = xcalloc(1, sizeof(*t));
+ t->repo = r;
strbuf_init(&t->path, 0);
strvec_init(&t->env);
* them.
*/
strbuf_addf(&t->path, "%s/tmp_objdir-%s-XXXXXX",
- repo_get_object_directory(the_repository), prefix);
+ repo_get_object_directory(r), prefix);
if (!mkdtemp(t->path.buf)) {
/* free, not destroy, as we never touched the filesystem */
}
env_append(&t->env, ALTERNATE_DB_ENVIRONMENT,
- absolute_path(repo_get_object_directory(the_repository)));
+ absolute_path(repo_get_object_directory(r)));
env_replace(&t->env, DB_ENVIRONMENT, absolute_path(t->path.buf));
env_replace(&t->env, GIT_QUARANTINE_ENVIRONMENT,
absolute_path(t->path.buf));
return 0;
if (t->prev_odb) {
- if (the_repository->objects->odb->will_destroy)
+ if (t->repo->objects->odb->will_destroy)
BUG("migrating an ODB that was marked for destruction");
restore_primary_odb(t->prev_odb, t->path.buf);
t->prev_odb = NULL;
}
strbuf_addbuf(&src, &t->path);
- strbuf_addstr(&dst, repo_get_object_directory(the_repository));
+ strbuf_addstr(&dst, repo_get_object_directory(t->repo));
ret = migrate_paths(&src, &dst, 0);
* Example:
*
* struct child_process child = CHILD_PROCESS_INIT;
- * struct tmp_objdir *t = tmp_objdir_create("incoming");
+ * struct tmp_objdir *t = tmp_objdir_create(repo, "incoming");
* strvec_push(&child.args, cmd);
* strvec_pushv(&child.env, tmp_objdir_env(t));
* if (!run_command(&child)) && !tmp_objdir_migrate(t))
*
*/
+struct repository;
struct tmp_objdir;
/*
* Create a new temporary object directory with the specified prefix;
* returns NULL on failure.
*/
-struct tmp_objdir *tmp_objdir_create(const char *prefix);
+struct tmp_objdir *tmp_objdir_create(struct repository *r, const char *prefix);
/*
* Return a list of environment strings, suitable for use with