Skip to content

Commit afc711b

Browse files
mhaggergitster
authored andcommitted
rename read_replace_refs to check_replace_refs
The semantics of this flag was changed in commit e1111ce inline lookup_replace_object() calls but wasn't renamed at the time to minimize code churn. Rename it now, and add a comment explaining its use. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f95c9f commit afc711b

File tree

12 files changed

+24
-14
lines changed

12 files changed

+24
-14
lines changed

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
630630
struct alternate_object_database *alt;
631631

632632
errors_found = 0;
633-
read_replace_refs = 0;
633+
check_replace_refs = 0;
634634

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

builtin/index-pack.c

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

1505-
read_replace_refs = 0;
1505+
check_replace_refs = 0;
15061506

15071507
reset_pack_idx_option(&opts);
15081508
git_config(git_index_pack_config, &opts);

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
25072507
OPT_END(),
25082508
};
25092509

2510-
read_replace_refs = 0;
2510+
check_replace_refs = 0;
25112511

25122512
reset_pack_idx_option(&pack_idx_opts);
25132513
git_config(git_pack_config, NULL);

builtin/prune.c

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

151151
expire = ULONG_MAX;
152152
save_commit_buffer = 0;
153-
read_replace_refs = 0;
153+
check_replace_refs = 0;
154154
init_revisions(&revs, prefix);
155155

156156
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
@@ -178,7 +178,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
178178
OPT_END()
179179
};
180180

181-
read_replace_refs = 0;
181+
check_replace_refs = 0;
182182

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

builtin/unpack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
497497
int i;
498498
unsigned char sha1[20];
499499

500-
read_replace_refs = 0;
500+
check_replace_refs = 0;
501501

502502
git_config(git_default_config, NULL);
503503

cache.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,17 @@ extern size_t packed_git_limit;
580580
extern size_t delta_base_cache_limit;
581581
extern unsigned long big_file_threshold;
582582
extern unsigned long pack_size_limit_cfg;
583-
extern int read_replace_refs;
583+
584+
/*
585+
* Do replace refs need to be checked this run? This variable is
586+
* initialized to true unless --no-replace-object is used or
587+
* $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some
588+
* commands that do not want replace references to be active. As an
589+
* optimization it is also set to false if replace references have
590+
* been sought but there were none.
591+
*/
592+
extern int check_replace_refs;
593+
584594
extern int fsync_object_files;
585595
extern int core_preload_index;
586596
extern int core_apply_sparse_checkout;
@@ -791,7 +801,7 @@ static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *
791801
extern const unsigned char *do_lookup_replace_object(const unsigned char *sha1);
792802
static inline const unsigned char *lookup_replace_object(const unsigned char *sha1)
793803
{
794-
if (!read_replace_refs)
804+
if (!check_replace_refs)
795805
return sha1;
796806
return do_lookup_replace_object(sha1);
797807
}

environment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const char *editor_program;
4545
const char *askpass_program;
4646
const char *excludes_file;
4747
enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
48-
int read_replace_refs = 1; /* NEEDSWORK: rename to use_replace_refs */
48+
int check_replace_refs = 1;
4949
enum eol core_eol = EOL_UNSET;
5050
enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
5151
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
@@ -147,7 +147,7 @@ static void setup_git_env(void)
147147
if (!git_graft_file)
148148
git_graft_file = git_pathdup("info/grafts");
149149
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
150-
read_replace_refs = 0;
150+
check_replace_refs = 0;
151151
namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
152152
namespace_len = strlen(namespace);
153153
shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
7878
if (envchanged)
7979
*envchanged = 1;
8080
} else if (!strcmp(cmd, "--no-replace-objects")) {
81-
read_replace_refs = 0;
81+
check_replace_refs = 0;
8282
setenv(NO_REPLACE_OBJECTS_ENVIRONMENT, "1", 1);
8383
if (envchanged)
8484
*envchanged = 1;

log-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
100100

101101
if (starts_with(refname, "refs/replace/")) {
102102
unsigned char original_sha1[20];
103-
if (!read_replace_refs)
103+
if (!check_replace_refs)
104104
return 0;
105105
if (get_sha1_hex(refname + 13, original_sha1)) {
106106
warning("invalid replace ref %s", refname);

0 commit comments

Comments
 (0)