submodule-config: allow submodule_free to handle arbitrary repositories
authorStefan Beller <sbeller@google.com>
Wed, 28 Mar 2018 22:35:28 +0000 (15:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 29 Mar 2018 16:44:50 +0000 (09:44 -0700)
At some point we may want to rename the function so that it describes what
it actually does as 'submodule_free' doesn't quite describe that this
clears a repository's submodule cache. But that's beyond the scope of
this series.

While at it remove the extern key word from its declaration.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/technical/api-submodule-config.txt
builtin/grep.c
submodule-config.c
submodule-config.h
t/helper/test-submodule-config.c
unpack-trees.c
index 3dce003fda008e61c7a91c85554f9a1cafe6106f..44a85bbb8bece89ce4aa8f15199af352b2084ed7 100644 (file)
@@ -38,7 +38,7 @@ Data Structures
 Functions
 ---------
 
 Functions
 ---------
 
-`void submodule_free()`::
+`void submodule_free(struct repository *r)`::
 
        Use these to free the internally cached values.
 
 
        Use these to free the internally cached values.
 
index 754eb6da3bf90768723e6eed04b7ff0d3a352a16..c1f22fb9fbaaed5bfc441641cd353ee16d887889 100644 (file)
@@ -643,7 +643,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
 
                /* load the gitmodules file for this rev */
                if (recurse_submodules) {
 
                /* load the gitmodules file for this rev */
                if (recurse_submodules) {
-                       submodule_free();
+                       submodule_free(the_repository);
                        gitmodules_config_oid(&real_obj->oid);
                }
                if (grep_object(opt, pathspec, real_obj, list->objects[i].name,
                        gitmodules_config_oid(&real_obj->oid);
                }
                if (grep_object(opt, pathspec, real_obj, list->objects[i].name,
index 2aa8a1747f8586839aa3036fbbc59f6c716c6128..5b4f0baae815bdfbc21651cdf2648f6c92dce3a6 100644 (file)
@@ -642,8 +642,8 @@ const struct submodule *submodule_from_cache(struct repository *repo,
                           key, lookup_path);
 }
 
                           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);
 }
 }
index a5503a5d177e90e009be9240bfddd68c9ead475b..6b71a8cd307794c686ed8a04dbcbde15f89252dc 100644 (file)
@@ -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 const struct submodule *submodule_from_cache(struct repository *repo,
                                                    const struct object_id *treeish_name,
                                                    const char *key);
-extern void submodule_free(void);
+void submodule_free(struct repository *r);
 
 #endif /* SUBMODULE_CONFIG_H */
 
 #endif /* SUBMODULE_CONFIG_H */
index f23db3b19a9911b554ca8eaf567cd0370d42af6e..9971c5e9dde3f91193c570be73ad141d95f9a21e 100644 (file)
@@ -64,7 +64,7 @@ int cmd_main(int argc, const char **argv)
                arg += 2;
        }
 
                arg += 2;
        }
 
-       submodule_free();
+       submodule_free(the_repository);
 
        return 0;
 }
 
        return 0;
 }
index e6a15bbe44f24555a8edb9461c2af553de70cba0..3a6a28e794cd311d0e39068840e0cb70d53ceaf5 100644 (file)
@@ -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)) {
                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);
                }
                        checkout_entry(ce, state, NULL);
                        repo_read_gitmodules(the_repository);
                }