Skip to content

Commit d9f9f6b

Browse files
committed
Merge branch 'ds/disable-replace-refs'
Introduce a mechanism to disable replace refs globally and per repository. * ds/disable-replace-refs: repository: create read_replace_refs setting replace-objects: create wrapper around setting repository: create disable_replace_refs()
2 parents f2ffc74 + 9c7d1b0 commit d9f9f6b

19 files changed

+111
-31
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
@@ -929,7 +929,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
929929
fetch_if_missing = 0;
930930

931931
errors_found = 0;
932-
read_replace_refs = 0;
932+
disable_replace_refs();
933933
save_commit_buffer = 0;
934934

935935
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

commit-graph.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,12 @@ static struct commit_graph *alloc_commit_graph(void)
204204
return g;
205205
}
206206

207-
extern int read_replace_refs;
208-
209207
static int commit_graph_compatible(struct repository *r)
210208
{
211209
if (!r->gitdir)
212210
return 0;
213211

214-
if (read_replace_refs) {
212+
if (replace_refs_enabled(r)) {
215213
prepare_replace_object(r);
216214
if (hashmap_get_size(&r->objects->replace_map->map))
217215
return 0;

0 commit comments

Comments
 (0)