config: add config_from_gitmodules
Add 'config_from_gitmodules()' function which can be used by 'fetch' and 'update_clone' in order to maintain backwards compatibility with configuration being stored in .gitmodules' since a future patch will remove reading these values in the submodule-config. This function should not be used anywhere other than in 'fetch' and 'update_clone'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Aug 2, 2017 at 12:49 UTC
b22e51cb26bc93bd1548950e61970a9973e04b70
2 files changed
+27
config.c
+17
@@ -2053,6 +2053,23 @@ int git_config_get_pathname(const char *key, const char **dest)
2053
return repo_config_get_pathname(the_repository, key, dest);
2054
}
2055
2056
+/*
2057
+ * Note: This function exists solely to maintain backward compatibility with
2058
+ * 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
2059
+ * NOT be used anywhere else.
2060
+ *
2061
+ * Runs the provided config function on the '.gitmodules' file found in the
2062
+ * working directory.
2063
+ */
2064
+void config_from_gitmodules(config_fn_t fn, void *data)
2065
+{
2066
+ if (the_repository->worktree) {
2067
+ char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
2068
+ git_config_from_file(fn, file, data);
2069
+ free(file);
2070
+ }
2071
+}
2072
+
2073
int git_config_get_expiry(const char *key, const char **output)
2074
{
2075
int ret = git_config_get_string_const(key, output);
config.h
+10
@@ -187,6 +187,16 @@ extern int repo_config_get_maybe_bool(struct repository *repo,
187
extern int repo_config_get_pathname(struct repository *repo,
188
const char *key, const char **dest);
189
190
+/*
191
+ * Note: This function exists solely to maintain backward compatibility with
192
+ * 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
193
+ * NOT be used anywhere else.
194
+ *
195
+ * Runs the provided config function on the '.gitmodules' file found in the
196
+ * working directory.
197
+ */
198
+extern void config_from_gitmodules(config_fn_t fn, void *data);
199
+
200
extern int git_config_get_value(const char *key, const char **value);
201
extern const struct string_list *git_config_get_value_multi(const char *key);
202
extern void git_config_clear(void);