submodule-config: allow submodule_free to handle arbitrary repositories
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>
Stefan Beller committed
Mar 28, 2018 at 15:35 UTC
f793b895fd752e37301702eaff948a40e7c0a4b8
6 files changed
+8
-8
Documentation/technical/api-submodule-config.txt
+1
-1
@@ -38,7 +38,7 @@ Data Structures
38
Functions
39
---------
40
41
-`void submodule_free()`::
41
+`void submodule_free(struct repository *r)`::
42
43
Use these to free the internally cached values.
44
builtin/grep.c
+1
-1
@@ -643,7 +643,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
643
644
/* load the gitmodules file for this rev */
645
if (recurse_submodules) {
646
- submodule_free();
646
+ submodule_free(the_repository);
647
gitmodules_config_oid(&real_obj->oid);
648
}
649
if (grep_object(opt, pathspec, real_obj, list->objects[i].name,
submodule-config.c
+3
-3
@@ -642,8 +642,8 @@ const struct submodule *submodule_from_cache(struct repository *repo,
642
key, lookup_path);
643
}
644
645
-void submodule_free(void)
645
+void submodule_free(struct repository *r)
646
{
647
- if (the_repository->submodule_cache)
648
- submodule_cache_clear(the_repository->submodule_cache);
647
+ if (r->submodule_cache)
648
+ submodule_cache_clear(r->submodule_cache);
649
}
submodule-config.h
+1
-1
@@ -46,6 +46,6 @@ extern const struct submodule *submodule_from_path(
46
extern const struct submodule *submodule_from_cache(struct repository *repo,
47
const struct object_id *treeish_name,
48
const char *key);
49
-extern void submodule_free(void);
49
+void submodule_free(struct repository *r);
50
51
#endif /* SUBMODULE_CONFIG_H */
t/helper/test-submodule-config.c
+1
-1
@@ -64,7 +64,7 @@ int cmd_main(int argc, const char **argv)
64
arg += 2;
65
}
66
67
- submodule_free();
67
+ submodule_free(the_repository);
68
69
return 0;
70
}
unpack-trees.c
+1
-1
@@ -290,7 +290,7 @@ static void load_gitmodules_file(struct index_state *index,
290
if (!state && ce->ce_flags & CE_WT_REMOVE) {
291
repo_read_gitmodules(the_repository);
292
} else if (state && (ce->ce_flags & CE_UPDATE)) {
293
- submodule_free();
293
+ submodule_free(the_repository);
294
checkout_entry(ce, state, NULL);
295
repo_read_gitmodules(the_repository);
296
}