summaryrefslogtreecommitdiff
path: root/submodule.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-03-14 21:46:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-16 01:15:54 (GMT)
commit84f8925eeb97827e9d334b8b9ff7282177ab9105 (patch)
treedd40bcd460d225043efc43feb8017a88e4624047 /submodule.c
parentcf055e465f6febedb8189407a901042814d6b5d8 (diff)
downloadgit-84f8925eeb97827e9d334b8b9ff7282177ab9105.zip
git-84f8925eeb97827e9d334b8b9ff7282177ab9105.tar.gz
git-84f8925eeb97827e9d334b8b9ff7282177ab9105.tar.bz2
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 <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule.c')
-rw-r--r--submodule.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/submodule.c b/submodule.c
index 591f4a6..8b2c021 100644
--- a/submodule.c
+++ b/submodule.c
@@ -548,6 +548,22 @@ void set_config_update_recurse_submodules(int value)
config_update_recurse_submodules = value;
}
+int should_update_submodules(void)
+{
+ return config_update_recurse_submodules == RECURSE_SUBMODULES_ON;
+}
+
+const struct submodule *submodule_from_ce(const struct cache_entry *ce)
+{
+ if (!S_ISGITLINK(ce->ce_mode))
+ return NULL;
+
+ if (!should_update_submodules())
+ return NULL;
+
+ return submodule_from_path(null_sha1, ce->name);
+}
+
static int has_remote(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
{