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>

Brandon Williams committed Jun 20, 2017 at 12:19 UTC bf08c8cfc1cff6aa4377efad8bdc166106b3a4d5
1 file changed +4 -5
environment.c
+4 -5
@@ -98,7 +98,6 @@ char *git_work_tree_cfg;
98 static char *work_tree;
99
100 static const char *namespace;
101 -static size_t namespace_len;
101
102 static const char *super_prefix;
103
@@ -190,7 +189,6 @@ void setup_git_env(void)
189 git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
190 : "refs/replace/");
191 namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
193 - namespace_len = strlen(namespace);
192 shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);
193 if (shallow_file)
194 set_alternate_shallow_file(shallow_file, 0);
@@ -231,9 +229,10 @@ const char *get_git_namespace(void)
229
230 const char *strip_namespace(const char *namespaced_ref)
231 {
234 - if (!starts_with(namespaced_ref, get_git_namespace()))
235 - return NULL;
236 - return namespaced_ref + namespace_len;
232 + const char *out;
233 + if (skip_prefix(namespaced_ref, get_git_namespace(), &out))
234 + return out;
235 + return NULL;
236 }
237
238 const char *get_super_prefix(void)