summaryrefslogtreecommitdiff
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorOrgad Shaneh <orgads@gmail.com>2020-09-04 13:50:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-06 16:50:49 (GMT)
commit7ea0c2f44dae65630e53bf36000933f8042eecda (patch)
treee64ff1703f227570ef99c1e855b05b56f4846b1b /builtin/fetch.c
parent3a238e539bcdfe3f9eb5010fd218640c1b499f7a (diff)
downloadgit-7ea0c2f44dae65630e53bf36000933f8042eecda.zip
git-7ea0c2f44dae65630e53bf36000933f8042eecda.tar.gz
git-7ea0c2f44dae65630e53bf36000933f8042eecda.tar.bz2
fetch: do not look for submodule changes in unchanged refs
When fetching recursively with submodules, for each ref in the superproject, we call check_for_new_submodule_commits() which collects all the objects that have to be checked for submodule changes on calculate_changed_submodule_paths(). On the first call, it also collects all the existing refs for excluding them from the scan. calculate_changed_submodule_paths() creates an argument array with all the collected new objects, followed by --not and all the old objects. This argv is passed to setup_revisions, which parses each argument, converts it back to an oid and resolves the object. The parsing itself also does redundant work, because it is treated like user input, while in fact it is a full oid. So it needlessly attempts to look it up as ref (checks if it has ^, ~ etc.), checks if it is a file name etc. For a repository with many refs, all of this is expensive. But if the fetch in the superproject did not update the ref (i.e. the objects that are required to exist in the submodule did not change), there is no need to include it in the list. Before commit be76c212 (fetch: ensure submodule objects fetched, 2018-12-06), submodule reference changes were only detected for refs that were changed, but not for new refs. This commit covered also this case, but what it did was to just include every ref. This change should reduce the number of scanned refs by about half (except the case of a no-op fetch, which will not scan any ref), because all the existing refs will still be listed after --not. The regression was reported here: https://public-inbox.org/git/CAGHpTBKSUJzFSWc=uznSu2zB33qCSmKXM- iAjxRCpqNK5bnhRg@mail.gmail.com/ Signed-off-by: Orgad Shaneh <orgads@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index a6d3268..b66e6c4 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -966,8 +966,10 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
ref->force = rm->peer_ref->force;
}
- if (recurse_submodules != RECURSE_SUBMODULES_OFF)
+ if (recurse_submodules != RECURSE_SUBMODULES_OFF &&
+ (!rm->peer_ref || !oideq(&ref->old_oid, &ref->new_oid))) {
check_for_new_submodule_commits(&rm->old_oid);
+ }
if (!strcmp(rm->name, "HEAD")) {
kind = "";