{"thread":{"id":"42162","subject":"[PATCH 2/2] submodule-config: don't shadow `cache`","startedAt":"2016-04-27T21:30:39Z","lastAt":"2016-04-27T21:30:40Z","messageCount":2,"participants":["Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"284752","messageId":"1461792640-18898-1-git-send-email-sbeller@google.com","threadId":"42162","inReplyTo":null,"subject":"[PATCH 1/2] config.c: drop local variable","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-27T21:30:39Z","receivedAt":"2016-04-27T21:30:39Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"As `ret` is not used for anything except determining an early return,\nwe don't need a variable for that. Drop it.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\nWhile reading config code, I found 2 nits. Both improve readability,\nno bugfix or feature.\n\nAs it is generally discouraged to have cleanup patch churn,\nI checked master..pu to see any possible topics in flight conflicting\non config.c or submodule-config.c and there is nothing close by.\n\nThanks,\nStefan\n\n config.c | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex 10b5c95..262d8d7 100644\n--- a/config.c\n+++ b/config.c\n@@ -1309,14 +1309,11 @@ static struct config_set_element *configset_find_element(struct config_set *cs,\n \tstruct config_set_element k;\n \tstruct config_set_element *found_entry;\n \tchar *normalized_key;\n-\tint ret;\n \t/*\n \t * `key` may come from the user, so normalize it before using it\n \t * for querying entries from the hashmap.\n \t */\n-\tret = git_config_parse_key(key, &normalized_key, NULL);\n-\n-\tif (ret)\n+\tif (git_config_parse_key(key, &normalized_key, NULL))\n \t\treturn NULL;\n \n \thashmap_entry_init(&k, strhash(normalized_key));\n-- \n2.8.0.41.g0ac0153.dirty\n"},{"id":"284751","messageId":"1461792640-18898-2-git-send-email-sbeller@google.com","threadId":"42162","inReplyTo":"1461792640-18898-1-git-send-email-sbeller@google.com","subject":"[PATCH 2/2] submodule-config: don't shadow `cache`","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-27T21:30:40Z","receivedAt":"2016-04-27T21:30:40Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Lots of internal functions in submodule-confic.c have a first parameter\n`struct submodule_cache *cache`, which currently always refers to the\nglobal variable `cache` in the file. To avoid confusion rename the\nglobal `cache` variable.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n submodule-config.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 8ac5031..debab29 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -30,7 +30,7 @@ enum lookup_type {\n \tlookup_path\n };\n \n-static struct submodule_cache cache;\n+static struct submodule_cache the_submodule_cache;\n static int is_cache_init;\n \n static int config_path_cmp(const struct submodule_entry *a,\n@@ -470,14 +470,14 @@ static void ensure_cache_init(void)\n \tif (is_cache_init)\n \t\treturn;\n \n-\tcache_init(&cache);\n+\tcache_init(&the_submodule_cache);\n \tis_cache_init = 1;\n }\n \n int parse_submodule_config_option(const char *var, const char *value)\n {\n \tstruct parse_config_parameter parameter;\n-\tparameter.cache = &cache;\n+\tparameter.cache = &the_submodule_cache;\n \tparameter.commit_sha1 = NULL;\n \tparameter.gitmodules_sha1 = null_sha1;\n \tparameter.overwrite = 1;\n@@ -490,18 +490,18 @@ const struct submodule *submodule_from_name(const unsigned char *commit_sha1,\n \t\tconst char *name)\n {\n \tensure_cache_init();\n-\treturn config_from_name(&cache, commit_sha1, name);\n+\treturn config_from_name(&the_submodule_cache, commit_sha1, name);\n }\n \n const struct submodule *submodule_from_path(const unsigned char *commit_sha1,\n \t\tconst char *path)\n {\n \tensure_cache_init();\n-\treturn config_from_path(&cache, commit_sha1, path);\n+\treturn config_from_path(&the_submodule_cache, commit_sha1, path);\n }\n \n void submodule_free(void)\n {\n-\tcache_free(&cache);\n+\tcache_free(&the_submodule_cache);\n \tis_cache_init = 0;\n }\n-- \n2.8.0.41.g0ac0153.dirty\n"}]}