git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 5/6] submodule-config: pass repository as argument to config_from_gitmodules

From
Antonio Ospite <ao2@ao2.it>
Date
Jun 26, 2018, 10:47 UTC
Message-ID
<20180626104710.9859-6-ao2@ao2.it>
In-Reply-To
<20180626104710.9859-1-ao2@ao2.it>
Generlize 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>
---
 submodule-config.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/submodule-config.c b/submodule-config.c
index cd1f1e06a..602c46af2 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -680,10 +680,10 @@ void submodule_free(struct repository *r)
  * Runs the provided config function on the '.gitmodules' file found in the
  * working directory.
  */
-static void config_from_gitmodules(config_fn_t fn, void *data)
+static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void *data)
 {
-	if (the_repository->worktree) {
-		char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
+	if (repo->worktree) {
+		char *file = repo_worktree_path(repo, GITMODULES_FILE);
 		git_config_from_file(fn, file, data);
 		free(file);
 	}
@@ -714,7 +714,7 @@ void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
 		.max_children = max_children,
 		.recurse_submodules = recurse_submodules
 	};
-	config_from_gitmodules(gitmodules_fetch_config, &config);
+	config_from_gitmodules(gitmodules_fetch_config, the_repository, &config);
 }
 
 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,
 
 void update_clone_config_from_gitmodules(int *max_jobs)
 {
-	config_from_gitmodules(gitmodules_update_clone_config, &max_jobs);
+	config_from_gitmodules(gitmodules_update_clone_config, the_repository, &max_jobs);
 }
-- 
2.18.0
Previous: Antonio OspiteNext: Junio C Hamano
Message 5 of 14 in “Restrict the usage of config_from_gitmodules to submodule-config”
  1. 0/6 Restrict the usage of config_from_gitmodules to submodule-configAntonio Ospite, Jun 26, 2018
  2. 1/6 config: move config_from_gitmodules to submodule-config.cAntonio Ospite, Jun 26, 2018
  3. 6/6 submodule-config: reuse config_from_gitmodules in repo_read_gitmodulesAntonio Ospite, Jun 26, 2018
  4. 3/6 submodule-config: add helper to get 'update-clone' config from .gitmodulesAntonio Ospite, Jun 26, 2018
  5. 5/6 submodule-config: pass repository as argument to config_from_gitmodulesAntonio Ospite, Jun 26, 2018
  6. Junio C HamanoJun 26, 2018
  7. Antonio OspiteJun 26, 2018
  8. 2/6 submodule-config: add helper function to get 'fetch' config from .gitmodulesAntonio Ospite, Jun 26, 2018
  9. Junio C HamanoJun 26, 2018
  10. Antonio OspiteJun 26, 2018
  11. 4/6 submodule-config: make 'config_from_gitmodules' privateAntonio Ospite, Jun 26, 2018
  12. Junio C HamanoJun 26, 2018
  13. Brandon WilliamsJun 26, 2018
  14. Junio C HamanoJun 26, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.