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

[PATCH 2/5] submodule-config: allow submodule_free to handle arbitrary repositories

From
Stefan Beller <sbeller@google.com>
Date
Mar 27, 2018, 21:39 UTC
Message-ID
<20180327213918.77851-3-sbeller@google.com>
In-Reply-To
<20180327213918.77851-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 Documentation/technical/api-submodule-config.txt | 2 +-
 builtin/grep.c                                   | 2 +-
 submodule-config.c                               | 6 +++---
 submodule-config.h                               | 2 +-
 t/helper/test-submodule-config.c                 | 2 +-
 unpack-trees.c                                   | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Documentation/technical/api-submodule-config.txt b/Documentation/technical/api-submodule-config.txt
index ee907c4a82..fb06089393 100644
--- a/Documentation/technical/api-submodule-config.txt
+++ b/Documentation/technical/api-submodule-config.txt
@@ -38,7 +38,7 @@ Data Structures
 Functions
 ---------
 
-`void submodule_free()`::
+`void submodule_free(struct repository *r)`::
 
 	Use these to free the internally cached values.
 
diff --git a/builtin/grep.c b/builtin/grep.c
index 789a89133a..8f04cde18e 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -651,7 +651,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
 
 		/* load the gitmodules file for this rev */
 		if (recurse_submodules) {
-			submodule_free();
+			submodule_free(repo);
 			gitmodules_config_oid(&real_obj->oid);
 		}
 		if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].path,
diff --git a/submodule-config.c b/submodule-config.c
index 602ba8ca8b..a3efff1a34 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -642,8 +642,8 @@ const struct submodule *submodule_from_cache(struct repository *repo,
 			   key, lookup_path);
 }
 
-void submodule_free(void)
+void submodule_free(struct repository *r)
 {
-	if (the_repository->submodule_cache)
-		submodule_cache_clear(the_repository->submodule_cache);
+	if (r->submodule_cache)
+		submodule_cache_clear(r->submodule_cache);
 }
diff --git a/submodule-config.h b/submodule-config.h
index a5503a5d17..df6bd6e6db 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -46,6 +46,6 @@ extern const struct submodule *submodule_from_path(
 extern const struct submodule *submodule_from_cache(struct repository *repo,
 						    const struct object_id *treeish_name,
 						    const char *key);
-extern void submodule_free(void);
+extern void submodule_free(struct repository *r);
 
 #endif /* SUBMODULE_CONFIG_H */
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index f23db3b19a..9971c5e9dd 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -64,7 +64,7 @@ int cmd_main(int argc, const char **argv)
 		arg += 2;
 	}
 
-	submodule_free();
+	submodule_free(the_repository);
 
 	return 0;
 }
diff --git a/unpack-trees.c b/unpack-trees.c
index d5685891a5..05e5fa77eb 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -290,7 +290,7 @@ static void load_gitmodules_file(struct index_state *index,
 		if (!state && ce->ce_flags & CE_WT_REMOVE) {
 			repo_read_gitmodules(the_repository);
 		} else if (state && (ce->ce_flags & CE_UPDATE)) {
-			submodule_free();
+			submodule_free(the_repository);
 			checkout_entry(ce, state, NULL);
 			repo_read_gitmodules(the_repository);
 		}
-- 
2.17.0.rc1.321.gba9d0f2565-goog
Previous: Stefan BellerNext: Brandon Williams
Message 6 of 36 in “Moving submodules with nested submodules”
  1. 0/5 Moving submodules with nested submodulesStefan Beller, Mar 27, 2018
  2. 1/5 submodule.h: drop declaration of connect_work_tree_and_git_dirStefan Beller, Mar 27, 2018
  3. 3/5 submodule-config: add repository argument to submodule_from_{name, path}Stefan Beller, Mar 27, 2018
  4. Jonathan TanMar 27, 2018
  5. Stefan BellerMar 27, 2018
  6. 2/5 submodule-config: allow submodule_free to handle arbitrary repositoriesStefan Beller, Mar 27, 2018
  7. Brandon WilliamsMar 27, 2018
  8. grep: remove "repo" arg from non-supporting funcsJonathan Tan, Mar 27, 2018
  9. Stefan BellerMar 27, 2018
  10. Jonathan TanMar 28, 2018
  11. Stefan BellerMar 28, 2018
  12. 5/5 submodule: fixup nested submodules after moving the submoduleStefan Beller, Mar 27, 2018
  13. Brandon WilliamsMar 27, 2018
  14. Jonathan TanMar 28, 2018
  15. Stefan BellerMar 28, 2018
  16. 0/6 Moving submodules with nested submodulesStefan Beller, Mar 28, 2018
  17. 1/6 submodule.h: drop declaration of connect_work_tree_and_git_dirStefan Beller, Mar 28, 2018
  18. 2/6 submodule-config: allow submodule_free to handle arbitrary repositoriesStefan Beller, Mar 28, 2018
  19. 4/6 submodule-config: remove submodule_from_cacheStefan Beller, Mar 28, 2018
  20. 5/6 submodule: fixup nested submodules after moving the submoduleStefan Beller, Mar 28, 2018
  21. Brandon WilliamsMar 28, 2018
  22. Stefan BellerMar 28, 2018
  23. Jonathan TanMar 28, 2018
  24. 3/6 submodule-config: add repository argument to submodule_from_{name, path}Stefan Beller, Mar 28, 2018
  25. 6/6 grep: remove "repo" arg from non-supporting funcsStefan Beller, Mar 28, 2018
  26. Jonathan TanMar 28, 2018
  27. 0/6 Moving submodules with nested submodulesStefan Beller, Mar 28, 2018
  28. 1/6 submodule.h: drop declaration of connect_work_tree_and_git_dirStefan Beller, Mar 28, 2018
  29. 2/6 grep: remove "repo" arg from non-supporting funcsStefan Beller, Mar 28, 2018
  30. 3/6 submodule-config: allow submodule_free to handle arbitrary repositoriesStefan Beller, Mar 28, 2018
  31. 6/6 submodule: fixup nested submodules after moving the submoduleStefan Beller, Mar 28, 2018
  32. 4/6 submodule-config: add repository argument to submodule_from_{name, path}Stefan Beller, Mar 28, 2018
  33. 5/6 submodule-config: remove submodule_from_cacheStefan Beller, Mar 28, 2018
  34. Jonathan TanMar 28, 2018
  35. 4/5 submodule-config: remove submodule_from_cacheStefan Beller, Mar 27, 2018
  36. Jonathan TanMar 27, 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.