From 84f8925eeb97827e9d334b8b9ff7282177ab9105 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Tue, 14 Mar 2017 14:46:34 -0700 Subject: submodules: introduce check to see whether to touch a submodule In later patches we introduce the --recurse-submodule flag for commands that modify the working directory, e.g. git-checkout. It is potentially expensive to check if a submodule needs an update, because a common theme to interact with submodules is to spawn a child process for each interaction. So let's introduce a function that checks if a submodule needs to be checked for an update before attempting the update. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- submodule.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'submodule.h') diff --git a/submodule.h b/submodule.h index b4e60c08d2..6f3fe85c7c 100644 --- a/submodule.h +++ b/submodule.h @@ -65,6 +65,13 @@ extern void show_submodule_inline_diff(FILE *f, const char *path, const struct diff_options *opt); extern void set_config_fetch_recurse_submodules(int value); extern void set_config_update_recurse_submodules(int value); +/* Check if we want to update any submodule.*/ +extern int should_update_submodules(void); +/* + * Returns the submodule struct if the given ce entry is a submodule + * and it should be updated. Returns NULL otherwise. + */ +extern const struct submodule *submodule_from_ce(const struct cache_entry *ce); extern void check_for_new_submodule_commits(unsigned char new_sha1[20]); extern int fetch_populated_submodules(const struct argv_array *options, const char *prefix, int command_line_option, -- cgit v1.2.3