summaryrefslogtreecommitdiff
path: root/environment.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-06-20 12:19:34 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-23 18:24:34 -0700
commitbf08c8cfc1cff6aa4377efad8bdc166106b3a4d5 (patch)
treed73b9723c582399f497d36fa3b81d75822cac3a2 /environment.c
parent7aee274fb4f3eb8d47ec9edce7042f809ce0e579 (diff)
downloadgit-bf08c8cfc1cff6aa4377efad8bdc166106b3a4d5.tar.gz
environment: remove namespace_len variable
Use 'skip_prefix' instead of 'starts_with' so that we can drop the need to keep around 'namespace_len'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'environment.c')
-rw-r--r--environment.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/environment.c b/environment.c
index a73b08f5d9..e035f6372e 100644
--- a/environment.c
+++ b/environment.c
@@ -98,7 +98,6 @@ char *git_work_tree_cfg;
static char *work_tree;
static const char *namespace;
-static size_t namespace_len;
static const char *super_prefix;
@@ -190,7 +189,6 @@ void setup_git_env(void)
git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
: "refs/replace/");
namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
- namespace_len = strlen(namespace);
shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);
if (shallow_file)
set_alternate_shallow_file(shallow_file, 0);
@@ -231,9 +229,10 @@ const char *get_git_namespace(void)
const char *strip_namespace(const char *namespaced_ref)
{
- if (!starts_with(namespaced_ref, get_git_namespace()))
- return NULL;
- return namespaced_ref + namespace_len;
+ const char *out;
+ if (skip_prefix(namespaced_ref, get_git_namespace(), &out))
+ return out;
+ return NULL;
}
const char *get_super_prefix(void)