Skip to content

Commit 3e30cb0

Browse files
committed
Merge branch 'mh/replace-refs-variable-rename'
* mh/replace-refs-variable-rename: Document some functions defined in object.c Add docstrings for lookup_replace_object() and do_lookup_replace_object() rename read_replace_refs to check_replace_refs
2 parents d552f8d + 33bef7e commit 3e30cb0

File tree

14 files changed

+79
-15
lines changed

14 files changed

+79
-15
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
@@ -2612,7 +2612,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
26122612
OPT_END(),
26132613
};
26142614

2615-
read_replace_refs = 0;
2615+
check_replace_refs = 0;
26162616

26172617
reset_pack_idx_option(&pack_idx_opts);
26182618
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: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,17 @@ extern size_t packed_git_limit;
581581
extern size_t delta_base_cache_limit;
582582
extern unsigned long big_file_threshold;
583583
extern unsigned long pack_size_limit_cfg;
584-
extern int read_replace_refs;
584+
585+
/*
586+
* Do replace refs need to be checked this run? This variable is
587+
* initialized to true unless --no-replace-object is used or
588+
* $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some
589+
* commands that do not want replace references to be active. As an
590+
* optimization it is also set to false if replace references have
591+
* been sought but there were none.
592+
*/
593+
extern int check_replace_refs;
594+
585595
extern int fsync_object_files;
586596
extern int core_preload_index;
587597
extern int core_apply_sparse_checkout;
@@ -808,13 +818,26 @@ static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *
808818
{
809819
return read_sha1_file_extended(sha1, type, size, LOOKUP_REPLACE_OBJECT);
810820
}
821+
822+
/*
823+
* This internal function is only declared here for the benefit of
824+
* lookup_replace_object(). Please do not call it directly.
825+
*/
811826
extern const unsigned char *do_lookup_replace_object(const unsigned char *sha1);
827+
828+
/*
829+
* If object sha1 should be replaced, return the replacement object's
830+
* name (replaced recursively, if necessary). The return value is
831+
* either sha1 or a pointer to a permanently-allocated value. When
832+
* object replacement is suppressed, always return sha1.
833+
*/
812834
static inline const unsigned char *lookup_replace_object(const unsigned char *sha1)
813835
{
814-
if (!read_replace_refs)
836+
if (!check_replace_refs)
815837
return sha1;
816838
return do_lookup_replace_object(sha1);
817839
}
840+
818841
static inline const unsigned char *lookup_replace_object_extended(const unsigned char *sha1, unsigned flag)
819842
{
820843
if (!(flag & LOOKUP_REPLACE_OBJECT))

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)