submodule-config: pass repository as argument to config_from_gitmodules
Generalize config_from_gitmodules() to accept a repository as an argument. This is in preparation to reuse the function in repo_read_gitmodules in order to have a single point where the '.gitmodules' file is accessed. 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
9a0fb3e772922685a8a3ed259afd52d097bd339c
1 file changed
+5
-5
submodule-config.c
+5
-5
@@ -680,10 +680,10 @@ void submodule_free(struct repository *r)
680
* Runs the provided config function on the '.gitmodules' file found in the
681
* working directory.
682
*/
683
-static void config_from_gitmodules(config_fn_t fn, void *data)
683
+static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void *data)
684
{
685
- if (the_repository->worktree) {
686
- char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
685
+ if (repo->worktree) {
686
+ char *file = repo_worktree_path(repo, GITMODULES_FILE);
687
git_config_from_file(fn, file, data);
688
free(file);
689
}
@@ -714,7 +714,7 @@ void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
714
.max_children = max_children,
715
.recurse_submodules = recurse_submodules
716
};
717
- config_from_gitmodules(gitmodules_fetch_config, &config);
717
+ config_from_gitmodules(gitmodules_fetch_config, the_repository, &config);
718
}
719
720
static int gitmodules_update_clone_config(const char *var, const char *value,
@@ -728,5 +728,5 @@ static int gitmodules_update_clone_config(const char *var, const char *value,
728
729
void update_clone_config_from_gitmodules(int *max_jobs)
730
{
731
- config_from_gitmodules(gitmodules_update_clone_config, &max_jobs);
731
+ config_from_gitmodules(gitmodules_update_clone_config, the_repository, &max_jobs);
732
}