Browse Source

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>
maint
Stefan Beller 7 years ago committed by Junio C Hamano
parent
commit
f793b895fd
  1. 2
      Documentation/technical/api-submodule-config.txt
  2. 2
      builtin/grep.c
  3. 6
      submodule-config.c
  4. 2
      submodule-config.h
  5. 2
      t/helper/test-submodule-config.c
  6. 2
      unpack-trees.c

2
Documentation/technical/api-submodule-config.txt

@ -38,7 +38,7 @@ Data Structures @@ -38,7 +38,7 @@ Data Structures
Functions
---------

`void submodule_free()`::
`void submodule_free(struct repository *r)`::

Use these to free the internally cached values.


2
builtin/grep.c

@ -643,7 +643,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec, @@ -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) {
submodule_free();
submodule_free(the_repository);
gitmodules_config_oid(&real_obj->oid);
}
if (grep_object(opt, pathspec, real_obj, list->objects[i].name,

6
submodule-config.c

@ -642,8 +642,8 @@ const struct submodule *submodule_from_cache(struct repository *repo, @@ -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);
}

2
submodule-config.h

@ -46,6 +46,6 @@ extern const struct submodule *submodule_from_path( @@ -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);
void submodule_free(struct repository *r);

#endif /* SUBMODULE_CONFIG_H */

2
t/helper/test-submodule-config.c

@ -64,7 +64,7 @@ int cmd_main(int argc, const char **argv) @@ -64,7 +64,7 @@ int cmd_main(int argc, const char **argv)
arg += 2;
}

submodule_free();
submodule_free(the_repository);

return 0;
}

2
unpack-trees.c

@ -290,7 +290,7 @@ static void load_gitmodules_file(struct index_state *index, @@ -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);
}

Loading…
Cancel
Save