{"thread":{"id":"35905","subject":"[PATCH] Rename read_replace_refs to check_replace_refs","startedAt":"2014-02-18T11:24:55Z","lastAt":"2014-02-18T21:30:54Z","messageCount":2,"participants":["Michael Haggerty","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"234961","messageId":"1392722695-31815-1-git-send-email-mhagger@alum.mit.edu","threadId":"35905","inReplyTo":null,"subject":"[PATCH] Rename read_replace_refs to check_replace_refs","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2014-02-18T11:24:55Z","receivedAt":"2014-02-18T11:24:55Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"The semantics of this flag was changed in commit\n\n    e1111cef23 inline lookup_replace_object() calls\n\nbut wasn't renamed at the time to minimize code churn.  Rename it now,\nand add a comment explaining its use.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\nThis change doesn't conflict with anything in pu; perhaps we can\nsqueeze it in now?\n\n builtin/fsck.c           |  2 +-\n builtin/index-pack.c     |  2 +-\n builtin/pack-objects.c   |  2 +-\n builtin/prune.c          |  2 +-\n builtin/replace.c        |  2 +-\n builtin/unpack-objects.c |  2 +-\n cache.h                  | 14 ++++++++++++--\n environment.c            |  4 ++--\n git.c                    |  2 +-\n log-tree.c               |  2 +-\n replace_object.c         |  2 +-\n upload-pack.c            |  2 +-\n 12 files changed, 24 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 1affdd5..3d42978 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -630,7 +630,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \tstruct alternate_object_database *alt;\n \n \terrors_found = 0;\n-\tread_replace_refs = 0;\n+\tcheck_replace_refs = 0;\n \n \targc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 2f37a38..a6b1c17 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -1502,7 +1502,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n \t\tusage(index_pack_usage);\n \n-\tread_replace_refs = 0;\n+\tcheck_replace_refs = 0;\n \n \treset_pack_idx_option(&opts);\n \tgit_config(git_index_pack_config, &opts);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 541667f..124015d 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2507,7 +2507,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\tOPT_END(),\n \t};\n \n-\tread_replace_refs = 0;\n+\tcheck_replace_refs = 0;\n \n \treset_pack_idx_option(&pack_idx_opts);\n \tgit_config(git_pack_config, NULL);\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex de43b26..68adc1c 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -150,7 +150,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)\n \n \texpire = ULONG_MAX;\n \tsave_commit_buffer = 0;\n-\tread_replace_refs = 0;\n+\tcheck_replace_refs = 0;\n \tinit_revisions(&revs, prefix);\n \n \targc = parse_options(argc, argv, prefix, options, prune_usage, 0);\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 2336325..8b59775 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -178,7 +178,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \n-\tread_replace_refs = 0;\n+\tcheck_replace_refs = 0;\n \n \targc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 62ff673..df2d3e3 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -497,7 +497,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)\n \tint i;\n \tunsigned char sha1[20];\n \n-\tread_replace_refs = 0;\n+\tcheck_replace_refs = 0;\n \n \tgit_config(git_default_config, NULL);\n \ndiff --git a/cache.h b/cache.h\nindex dc040fb..b039abc 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -580,7 +580,17 @@ extern size_t packed_git_limit;\n extern size_t delta_base_cache_limit;\n extern unsigned long big_file_threshold;\n extern unsigned long pack_size_limit_cfg;\n-extern int read_replace_refs;\n+\n+/*\n+ * Do replace refs need to be checked this run?  This variable is\n+ * initialized to true unless --no-replace-object is used or\n+ * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some\n+ * commands that do not want replace references to be active.  As an\n+ * optimization it is also set to false if replace references have\n+ * been sought but there were none.\n+ */\n+extern int check_replace_refs;\n+\n extern int fsync_object_files;\n extern int core_preload_index;\n extern int core_apply_sparse_checkout;\n@@ -791,7 +801,7 @@ static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *\n extern const unsigned char *do_lookup_replace_object(const unsigned char *sha1);\n static inline const unsigned char *lookup_replace_object(const unsigned char *sha1)\n {\n-\tif (!read_replace_refs)\n+\tif (!check_replace_refs)\n \t\treturn sha1;\n \treturn do_lookup_replace_object(sha1);\n }\ndiff --git a/environment.c b/environment.c\nindex 4a3437d..c3c8606 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -45,7 +45,7 @@ const char *editor_program;\n const char *askpass_program;\n const char *excludes_file;\n enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;\n-int read_replace_refs = 1; /* NEEDSWORK: rename to use_replace_refs */\n+int check_replace_refs = 1;\n enum eol core_eol = EOL_UNSET;\n enum safe_crlf safe_crlf = SAFE_CRLF_WARN;\n unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;\n@@ -147,7 +147,7 @@ static void setup_git_env(void)\n \tif (!git_graft_file)\n \t\tgit_graft_file = git_pathdup(\"info/grafts\");\n \tif (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))\n-\t\tread_replace_refs = 0;\n+\t\tcheck_replace_refs = 0;\n \tnamespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));\n \tnamespace_len = strlen(namespace);\n \tshallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);\ndiff --git a/git.c b/git.c\nindex 7cf2953..9efd1a3 100644\n--- a/git.c\n+++ b/git.c\n@@ -78,7 +78,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\n \t\t} else if (!strcmp(cmd, \"--no-replace-objects\")) {\n-\t\t\tread_replace_refs = 0;\n+\t\t\tcheck_replace_refs = 0;\n \t\t\tsetenv(NO_REPLACE_OBJECTS_ENVIRONMENT, \"1\", 1);\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\ndiff --git a/log-tree.c b/log-tree.c\nindex 08970bf..5ce217d 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -100,7 +100,7 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in\n \n \tif (starts_with(refname, \"refs/replace/\")) {\n \t\tunsigned char original_sha1[20];\n-\t\tif (!read_replace_refs)\n+\t\tif (!check_replace_refs)\n \t\t\treturn 0;\n \t\tif (get_sha1_hex(refname + 13, original_sha1)) {\n \t\t\twarning(\"invalid replace ref %s\", refname);\ndiff --git a/replace_object.c b/replace_object.c\nindex cdcaf8c..c5cf9f4 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -86,7 +86,7 @@ static void prepare_replace_object(void)\n \tfor_each_replace_ref(register_replace_ref, NULL);\n \treplace_object_prepared = 1;\n \tif (!replace_object_nr)\n-\t\tread_replace_refs = 0;\n+\t\tcheck_replace_refs = 0;\n }\n \n /* We allow \"recursive\" replacement. Only within reason, though */\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 0c44f6b..9314c25 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -796,7 +796,7 @@ int main(int argc, char **argv)\n \n \tpacket_trace_identity(\"upload-pack\");\n \tgit_extract_argv0_path(argv[0]);\n-\tread_replace_refs = 0;\n+\tcheck_replace_refs = 0;\n \n \tfor (i = 1; i < argc; i++) {\n \t\tchar *arg = argv[i];\n-- \n1.8.5.3\n"},{"id":"235024","messageId":"xmqqppmkcdm9.fsf@gitster.dls.corp.google.com","threadId":"35905","inReplyTo":"1392722695-31815-1-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH] Rename read_replace_refs to check_replace_refs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-18T21:30:54Z","receivedAt":"2014-02-18T21:30:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> The semantics of this flag was changed in commit\n>\n>     e1111cef23 inline lookup_replace_object() calls\n>\n> but wasn't renamed at the time to minimize code churn.  Rename it now,\n> and add a comment explaining its use.\n>\n> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n> ---\n> This change doesn't conflict with anything in pu; perhaps we can\n> squeeze it in now?\n\nI think it is a good time to do this kind of clean-up once the\npost-release dusts settle.\n\nThanks.\n"}]}