Merge branch 'sb/misc-cleanups'
* sb/misc-cleanups: submodule-config: don't shadow `cache` config.c: drop local variable
This commit is contained in:
commit
934908ae5b
5
config.c
5
config.c
@ -1309,14 +1309,11 @@ static struct config_set_element *configset_find_element(struct config_set *cs,
|
|||||||
struct config_set_element k;
|
struct config_set_element k;
|
||||||
struct config_set_element *found_entry;
|
struct config_set_element *found_entry;
|
||||||
char *normalized_key;
|
char *normalized_key;
|
||||||
int ret;
|
|
||||||
/*
|
/*
|
||||||
* `key` may come from the user, so normalize it before using it
|
* `key` may come from the user, so normalize it before using it
|
||||||
* for querying entries from the hashmap.
|
* for querying entries from the hashmap.
|
||||||
*/
|
*/
|
||||||
ret = git_config_parse_key(key, &normalized_key, NULL);
|
if (git_config_parse_key(key, &normalized_key, NULL))
|
||||||
|
|
||||||
if (ret)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
hashmap_entry_init(&k, strhash(normalized_key));
|
hashmap_entry_init(&k, strhash(normalized_key));
|
||||||
|
@ -30,7 +30,7 @@ enum lookup_type {
|
|||||||
lookup_path
|
lookup_path
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct submodule_cache cache;
|
static struct submodule_cache the_submodule_cache;
|
||||||
static int is_cache_init;
|
static int is_cache_init;
|
||||||
|
|
||||||
static int config_path_cmp(const struct submodule_entry *a,
|
static int config_path_cmp(const struct submodule_entry *a,
|
||||||
@ -470,14 +470,14 @@ static void ensure_cache_init(void)
|
|||||||
if (is_cache_init)
|
if (is_cache_init)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cache_init(&cache);
|
cache_init(&the_submodule_cache);
|
||||||
is_cache_init = 1;
|
is_cache_init = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_submodule_config_option(const char *var, const char *value)
|
int parse_submodule_config_option(const char *var, const char *value)
|
||||||
{
|
{
|
||||||
struct parse_config_parameter parameter;
|
struct parse_config_parameter parameter;
|
||||||
parameter.cache = &cache;
|
parameter.cache = &the_submodule_cache;
|
||||||
parameter.commit_sha1 = NULL;
|
parameter.commit_sha1 = NULL;
|
||||||
parameter.gitmodules_sha1 = null_sha1;
|
parameter.gitmodules_sha1 = null_sha1;
|
||||||
parameter.overwrite = 1;
|
parameter.overwrite = 1;
|
||||||
@ -490,18 +490,18 @@ const struct submodule *submodule_from_name(const unsigned char *commit_sha1,
|
|||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
ensure_cache_init();
|
ensure_cache_init();
|
||||||
return config_from_name(&cache, commit_sha1, name);
|
return config_from_name(&the_submodule_cache, commit_sha1, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
|
const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
ensure_cache_init();
|
ensure_cache_init();
|
||||||
return config_from_path(&cache, commit_sha1, path);
|
return config_from_path(&the_submodule_cache, commit_sha1, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void submodule_free(void)
|
void submodule_free(void)
|
||||||
{
|
{
|
||||||
cache_free(&cache);
|
cache_free(&the_submodule_cache);
|
||||||
is_cache_init = 0;
|
is_cache_init = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user