* Disable ref updates while a temporary odb is active, since
* the objects in the database may roll back.
*/
- source->disable_ref_updates = 1;
+ odb->repo->disable_ref_updates = true;
source->will_destroy = will_destroy;
source->next = odb->sources;
odb->sources = source;
if (cur_source->next != restore_source)
BUG("we expect the old primary object store to be the first alternate");
+ odb->repo->disable_ref_updates = false;
odb->sources = restore_source;
odb_source_free(cur_source);
}
*/
bool local;
- /*
- * This is a temporary object store created by the tmp_objdir
- * facility. Disable ref updates since the objects in the store
- * might be discarded on rollback.
- */
- int disable_ref_updates;
-
/*
* This object store is ephemeral, so there is no need to fsync.
*/
break;
}
- if (refs->repo->objects->sources->disable_ref_updates) {
+ if (refs->repo->disable_ref_updates) {
strbuf_addstr(err,
_("ref updates forbidden inside quarantine environment"));
return -1;
repo->objects->sources->path = objects_path;
}
- repo->objects->sources->disable_ref_updates = o->disable_ref_updates;
+ repo->disable_ref_updates = o->disable_ref_updates;
free(repo->objects->alternate_db);
repo->objects->alternate_db = xstrdup_or_null(o->alternate_db);
*/
struct ref_store *refs_private;
+ /*
+ * Disable ref updates. This is especially used in contexts where
+ * transactions may still be rolled back so that we don't start to
+ * reference objects that may vanish.
+ */
+ bool disable_ref_updates;
+
/*
* A strmap of ref_stores, stored by submodule name, accessible via
* `repo_get_submodule_ref_store()`.
const char *graft_file;
const char *index_file;
const char *alternate_db;
- int disable_ref_updates;
+ bool disable_ref_updates;
};
void repo_set_gitdir(struct repository *repo, const char *root,
args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT);
args.alternate_db = getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT);
if (getenv(GIT_QUARANTINE_ENVIRONMENT)) {
- args.disable_ref_updates = 1;
+ args.disable_ref_updates = true;
}
repo_set_gitdir(the_repository, git_dir, &args);