Skip to content

Commit d24eda4

Browse files
derrickstoleegitster
authored andcommitted
repository: create disable_replace_refs()
Several builtins depend on being able to disable the replace references so we actually operate on each object individually. These currently do so by directly mutating the 'read_replace_refs' global. A future change will move this global into a different place, so it will be necessary to change all of these lines. However, we can simplify that transition by abstracting the purpose of these global assignments with a method call. We will need to keep this read_replace_refs global forever, as we want to make sure that we never use replace refs throughout the life of the process if this method is called. Future changes may present a repository-scoped version of the variable to represent that repository's core.useReplaceRefs config value, but a zero-valued read_replace_refs will always override such a setting. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b0afdce commit d24eda4

13 files changed

+24
-11
lines changed

builtin/cat-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ static int batch_objects(struct batch_options *opt)
805805
if (repo_has_promisor_remote(the_repository))
806806
warning("This repository uses promisor remotes. Some objects may not be loaded.");
807807

808-
read_replace_refs = 0;
808+
disable_replace_refs();
809809

810810
cb.opt = opt;
811811
cb.expand = &data;

builtin/commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
324324

325325
git_config(git_default_config, NULL);
326326

327-
read_replace_refs = 0;
327+
disable_replace_refs();
328328
save_commit_buffer = 0;
329329

330330
argc = parse_options(argc, argv, prefix, options,

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
927927
fetch_if_missing = 0;
928928

929929
errors_found = 0;
930-
read_replace_refs = 0;
930+
disable_replace_refs();
931931
save_commit_buffer = 0;
932932

933933
argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
17521752
if (argc == 2 && !strcmp(argv[1], "-h"))
17531753
usage(index_pack_usage);
17541754

1755-
read_replace_refs = 0;
1755+
disable_replace_refs();
17561756
fsck_options.walk = mark_link;
17571757

17581758
reset_pack_idx_option(&opts);

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4284,7 +4284,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
42844284
if (DFS_NUM_STATES > (1 << OE_DFS_STATE_BITS))
42854285
BUG("too many dfs states, increase OE_DFS_STATE_BITS");
42864286

4287-
read_replace_refs = 0;
4287+
disable_replace_refs();
42884288

42894289
sparse = git_env_bool("GIT_TEST_PACK_SPARSE", -1);
42904290
if (the_repository->gitdir) {

builtin/prune.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
164164

165165
expire = TIME_MAX;
166166
save_commit_buffer = 0;
167-
read_replace_refs = 0;
167+
disable_replace_refs();
168168
repo_init_revisions(the_repository, &revs, prefix);
169169

170170
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);

builtin/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
566566
OPT_END()
567567
};
568568

569-
read_replace_refs = 0;
569+
disable_replace_refs();
570570
git_config(git_default_config, NULL);
571571

572572
argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);

builtin/unpack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)
609609
int i;
610610
struct object_id oid;
611611

612-
read_replace_refs = 0;
612+
disable_replace_refs();
613613

614614
git_config(git_default_config, NULL);
615615

builtin/upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int cmd_upload_pack(int argc, const char **argv, const char *prefix)
3636
};
3737

3838
packet_trace_identity("upload-pack");
39-
read_replace_refs = 0;
39+
disable_replace_refs();
4040

4141
argc = parse_options(argc, argv, prefix, options, upload_pack_usage, 0);
4242

environment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void setup_git_env(const char *git_dir)
185185
strvec_clear(&to_free);
186186

187187
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
188-
read_replace_refs = 0;
188+
disable_replace_refs();
189189
replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT);
190190
git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
191191
: "refs/replace/");

0 commit comments

Comments
 (0)