diff options
author | Derrick Stolee <derrickstolee@github.com> | 2022-08-05 17:58:37 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-08-05 21:13:12 (GMT) |
commit | 97e61e0f9cd96f403504ec97cfdf38f238777560 (patch) | |
tree | 2ad031cf850eae3080ada2e74e5aa51ee092048d /builtin/replace.c | |
parent | b9342b3fd6308c351f53075c9c4339913b73451f (diff) | |
download | git-97e61e0f9cd96f403504ec97cfdf38f238777560.zip git-97e61e0f9cd96f403504ec97cfdf38f238777560.tar.gz git-97e61e0f9cd96f403504ec97cfdf38f238777560.tar.bz2 |
refs: use ref_namespaces for replace refs base
The git_replace_ref_base global is used to store the value of the
GIT_REPLACE_REF_BASE environment variable or the default of
"refs/replace/". This is initialized within setup_git_env().
The ref_namespaces array is a new centralized location for information
such as the ref namespace used for replace refs. Instead of having this
namespace stored in two places, use the ref_namespaces array instead.
For simplicity, create a local git_replace_ref_base variable wherever
the global was previously used.
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/replace.c')
-rw-r--r-- | builtin/replace.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/replace.c b/builtin/replace.c index 583702a..a29e911 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -106,6 +106,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn) size_t base_len; int had_error = 0; struct object_id oid; + const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref; strbuf_addstr(&ref, git_replace_ref_base); base_len = ref.len; @@ -147,6 +148,8 @@ static int check_ref_valid(struct object_id *object, struct strbuf *ref, int force) { + const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref; + strbuf_reset(ref); strbuf_addf(ref, "%s%s", git_replace_ref_base, oid_to_hex(object)); if (check_refname_format(ref->buf, 0)) |