config: move config_from_gitmodules to submodule-config.c

The .gitmodules file is not meant as a place to store arbitrary configuration to distribute with the repository. Move config_from_gitmodules() out of config.c and into submodule-config.c to make it even clearer that it is not a mechanism to retrieve arbitrary configuration from the .gitmodules file. Signed-off-by: Antonio Ospite <ao2@ao2.it> Acked-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Antonio Ospite committed Jun 26, 2018 at 12:47 UTC ad136370b2a26fd55f446722ff7bf5b383e8eca0
4 files changed +28 -27
config.c
-17
@@ -2172,23 +2172,6 @@ int git_config_get_pathname(const char *key, const char **dest)
2172 return repo_config_get_pathname(the_repository, key, dest);
2173 }
2174
2175 -/*
2176 - * Note: This function exists solely to maintain backward compatibility with
2177 - * 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
2178 - * NOT be used anywhere else.
2179 - *
2180 - * Runs the provided config function on the '.gitmodules' file found in the
2181 - * working directory.
2182 - */
2183 -void config_from_gitmodules(config_fn_t fn, void *data)
2184 -{
2185 - if (the_repository->worktree) {
2186 - char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
2187 - git_config_from_file(fn, file, data);
2188 - free(file);
2189 - }
2190 -}
2191 -
2175 int git_config_get_expiry(const char *key, const char **output)
2176 {
2177 int ret = git_config_get_string_const(key, output);
config.h
-10
@@ -215,16 +215,6 @@ extern int repo_config_get_maybe_bool(struct repository *repo,
215 extern int repo_config_get_pathname(struct repository *repo,
216 const char *key, const char **dest);
217
218 -/*
219 - * Note: This function exists solely to maintain backward compatibility with
220 - * 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
221 - * NOT be used anywhere else.
222 - *
223 - * Runs the provided config function on the '.gitmodules' file found in the
224 - * working directory.
225 - */
226 -extern void config_from_gitmodules(config_fn_t fn, void *data);
227 -
218 extern int git_config_get_value(const char *key, const char **value);
219 extern const struct string_list *git_config_get_value_multi(const char *key);
220 extern void git_config_clear(void);
submodule-config.c
+17
@@ -671,3 +671,20 @@ void submodule_free(struct repository *r)
671 if (r->submodule_cache)
672 submodule_cache_clear(r->submodule_cache);
673 }
674 +
675 +/*
676 + * Note: This function exists solely to maintain backward compatibility with
677 + * 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
678 + * NOT be used anywhere else.
679 + *
680 + * Runs the provided config function on the '.gitmodules' file found in the
681 + * working directory.
682 + */
683 +void config_from_gitmodules(config_fn_t fn, void *data)
684 +{
685 + if (the_repository->worktree) {
686 + char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
687 + git_config_from_file(fn, file, data);
688 + free(file);
689 + }
690 +}
submodule-config.h
+11
@@ -2,6 +2,7 @@
2 #define SUBMODULE_CONFIG_CACHE_H
3
4 #include "cache.h"
5 +#include "config.h"
6 #include "hashmap.h"
7 #include "submodule.h"
8 #include "strbuf.h"
@@ -55,4 +56,14 @@ void submodule_free(struct repository *r);
56 */
57 int check_submodule_name(const char *name);
58
59 +/*
60 + * Note: This function exists solely to maintain backward compatibility with
61 + * 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
62 + * NOT be used anywhere else.
63 + *
64 + * Runs the provided config function on the '.gitmodules' file found in the
65 + * working directory.
66 + */
67 +extern void config_from_gitmodules(config_fn_t fn, void *data);
68 +
69 #endif /* SUBMODULE_CONFIG_H */