Skip to content

Commit f793b89

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6856077 commit f793b89

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

Documentation/technical/api-submodule-config.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Data Structures
3838
Functions
3939
---------
4040

41-
`void submodule_free()`::
41+
`void submodule_free(struct repository *r)`::
4242

4343
Use these to free the internally cached values.
4444

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
643643

644644
/* load the gitmodules file for this rev */
645645
if (recurse_submodules) {
646-
submodule_free();
646+
submodule_free(the_repository);
647647
gitmodules_config_oid(&real_obj->oid);
648648
}
649649
if (grep_object(opt, pathspec, real_obj, list->objects[i].name,

submodule-config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,8 @@ const struct submodule *submodule_from_cache(struct repository *repo,
642642
key, lookup_path);
643643
}
644644

645-
void submodule_free(void)
645+
void submodule_free(struct repository *r)
646646
{
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);
649649
}

submodule-config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ extern const struct submodule *submodule_from_path(
4646
extern const struct submodule *submodule_from_cache(struct repository *repo,
4747
const struct object_id *treeish_name,
4848
const char *key);
49-
extern void submodule_free(void);
49+
void submodule_free(struct repository *r);
5050

5151
#endif /* SUBMODULE_CONFIG_H */

t/helper/test-submodule-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int cmd_main(int argc, const char **argv)
6464
arg += 2;
6565
}
6666

67-
submodule_free();
67+
submodule_free(the_repository);
6868

6969
return 0;
7070
}

unpack-trees.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static void load_gitmodules_file(struct index_state *index,
290290
if (!state && ce->ce_flags & CE_WT_REMOVE) {
291291
repo_read_gitmodules(the_repository);
292292
} else if (state && (ce->ce_flags & CE_UPDATE)) {
293-
submodule_free();
293+
submodule_free(the_repository);
294294
checkout_entry(ce, state, NULL);
295295
repo_read_gitmodules(the_repository);
296296
}

0 commit comments

Comments
 (0)