+4
index e3a285a08f..d797f173b0 100644
--- a/environment.c
+++ b/environment.c
args.graft_file = getenv_safe(&to_free, GRAFT_ENVIRONMENT);
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;
+ }
+
repo_set_gitdir(the_repository, git_dir, &args);
strvec_clear(&to_free);
+6
index 990381abee..f16441afb9 100644
--- a/object-file.c
+++ b/object-file.c
*/
new_odb = xcalloc(1, sizeof(*new_odb));
new_odb->path = xstrdup(dir);
+
+ /*
+ * Disable ref updates while a temporary odb is active, since
+ * the objects in the database may roll back.
+ */
+ new_odb->disable_ref_updates = 1;
new_odb->will_destroy = will_destroy;
new_odb->next = the_repository->objects->odb;
the_repository->objects->odb = new_odb;
+7
index 74b1b5872a..62a0c97f27 100644
--- a/object-store.h
+++ b/object-store.h
uint32_t loose_objects_subdir_seen[8]; /* 256 bits */
struct oidtree *loose_objects_cache;
+ /*
+ * 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.
*/
+1
-1
index 8b9f7c3a80..b49864fc1a 100644
--- a/refs.c
+++ b/refs.c
break;
}
- if (getenv(GIT_QUARANTINE_ENVIRONMENT)) {
+ if (refs->repo->objects->odb->disable_ref_updates) {
strbuf_addstr(err,
_("ref updates forbidden inside quarantine environment"));
return -1;
+2
index 710a3b4bf8..18e0526da0 100644
--- a/repository.c
+++ b/repository.c
expand_base_dir(&repo->objects->odb->path, o->object_dir,
repo->commondir, "objects");
+ repo->objects->odb->disable_ref_updates = o->disable_ref_updates;
+
free(repo->objects->alternate_db);
repo->objects->alternate_db = xstrdup_or_null(o->alternate_db);
expand_base_dir(&repo->graft_file, o->graft_file,
+1
index 3740c93bc0..77316367d9 100644
--- a/repository.h
+++ b/repository.h
const char *graft_file;
const char *index_file;
const char *alternate_db;
+ int disable_ref_updates;
};
void repo_set_gitdir(struct repository *repo, const char *root,