summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-08-02 19:49:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-08-02 21:26:46 (GMT)
commitb22e51cb26bc93bd1548950e61970a9973e04b70 (patch)
treea9f4a6e1d69b52f3c6775e50853080e6b9e0f2fe /config.c
parent4c0eeafe4755345b0f4636bf09904cf689703e11 (diff)
downloadgit-b22e51cb26bc93bd1548950e61970a9973e04b70.zip
git-b22e51cb26bc93bd1548950e61970a9973e04b70.tar.gz
git-b22e51cb26bc93bd1548950e61970a9973e04b70.tar.bz2
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>
Diffstat (limited to 'config.c')
-rw-r--r--config.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/config.c b/config.c
index 231f9a7..06645a3 100644
--- a/config.c
+++ b/config.c
@@ -2053,6 +2053,23 @@ int git_config_get_pathname(const char *key, const char **dest)
return repo_config_get_pathname(the_repository, key, dest);
}
+/*
+ * Note: This function exists solely to maintain backward compatibility with
+ * 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
+ * NOT be used anywhere else.
+ *
+ * Runs the provided config function on the '.gitmodules' file found in the
+ * working directory.
+ */
+void config_from_gitmodules(config_fn_t fn, void *data)
+{
+ if (the_repository->worktree) {
+ char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
+ git_config_from_file(fn, file, data);
+ free(file);
+ }
+}
+
int git_config_get_expiry(const char *key, const char **output)
{
int ret = git_config_get_string_const(key, output);