+1
-1
index 0bafc14e6c..27f070267a 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
if (repo_has_promisor_remote(the_repository))
warning("This repository uses promisor remotes. Some objects may not be loaded.");
- read_replace_refs = 0;
+ disable_replace_refs();
cb.opt = opt;
cb.expand = &data;
+1
-1
index a3d00fa232..dd732b3534 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
git_config(git_default_config, NULL);
- read_replace_refs = 0;
+ disable_replace_refs();
save_commit_buffer = 0;
argc = parse_options(argc, argv, prefix, options,
+1
-1
index 2cd461b84c..a2fe760cc0 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
fetch_if_missing = 0;
errors_found = 0;
- read_replace_refs = 0;
+ disable_replace_refs();
save_commit_buffer = 0;
argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);
+1
-1
index bb67e16655..d0d8067510 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(index_pack_usage);
- read_replace_refs = 0;
+ disable_replace_refs();
fsck_options.walk = mark_link;
reset_pack_idx_option(&opts);
+1
-1
index a5b466839b..e23fe82ca1 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
if (DFS_NUM_STATES > (1 << OE_DFS_STATE_BITS))
BUG("too many dfs states, increase OE_DFS_STATE_BITS");
- read_replace_refs = 0;
+ disable_replace_refs();
sparse = git_env_bool("GIT_TEST_PACK_SPARSE", -1);
if (the_repository->gitdir) {
+1
-1
index 5dc9b20720..2877201737 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
expire = TIME_MAX;
save_commit_buffer = 0;
- read_replace_refs = 0;
+ disable_replace_refs();
repo_init_revisions(the_repository, &revs, prefix);
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
+1
-1
index 981f189443..abff800276 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
OPT_END()
};
- read_replace_refs = 0;
+ disable_replace_refs();
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
+1
-1
index 2c52c3a741..0b4fe803cc 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
int i;
struct object_id oid;
- read_replace_refs = 0;
+ disable_replace_refs();
git_config(git_default_config, NULL);
+1
-1
index beb9dd0861..81d2008e01 100644
--- a/builtin/upload-pack.c
+++ b/builtin/upload-pack.c
};
packet_trace_identity("upload-pack");
- read_replace_refs = 0;
+ disable_replace_refs();
argc = parse_options(argc, argv, prefix, options, upload_pack_usage, 0);
+1
-1
index 8a96997539..3b4d87c322 100644
--- a/environment.c
+++ b/environment.c
strvec_clear(&to_free);
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
- read_replace_refs = 0;
+ disable_replace_refs();
replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT);
git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
: "refs/replace/");
+1
-1
index 45899be826..3252d4c766 100644
--- a/git.c
+++ b/git.c
if (envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--no-replace-objects")) {
- read_replace_refs = 0;
+ disable_replace_refs();
setenv(NO_REPLACE_OBJECTS_ENVIRONMENT, "1", 1);
if (envchanged)
*envchanged = 1;
+5
index e98825d585..ceec81c940 100644
--- a/replace-object.c
+++ b/replace-object.c
}
die(_("replace depth too high for object %s"), oid_to_hex(oid));
}
+
+void disable_replace_refs(void)
+{
+ read_replace_refs = 0;
+}
+8
index 500482b02b..7786d4152b 100644
--- a/replace-object.h
+++ b/replace-object.h
return do_lookup_replace_object(r, oid);
}
+/*
+ * Some commands override config and environment settings for using
+ * replace references. Use this method to disable the setting and ensure
+ * those other settings will not override this choice. This applies
+ * globally to all in-process repositories.
+ */
+void disable_replace_refs(void);
+
#endif /* REPLACE_OBJECT_H */