]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: forgo full connectivity check if --filter
authorJonathan Tan <jonathantanmy@google.com>
Sun, 12 Jan 2020 04:15:25 +0000 (20:15 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Jan 2020 18:55:47 +0000 (10:55 -0800)
If a filter is specified, we do not need a full connectivity check on
the contents of the packfile we just fetched; we only need to check that
the objects referenced are promisor objects.

This significantly speeds up fetches into repositories that have many
promisor objects, because during the connectivity check, all promisor
objects are enumerated (to mark them UNINTERESTING), and that takes a
significant amount of time.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c

index b4c6d921d063734313f6d9c4746bfe7835885555..6fb50320eb6ed354ede802a0c6d1805feb6db4f2 100644 (file)
@@ -906,8 +906,17 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
                url = xstrdup("foreign");
 
        if (!connectivity_checked) {
+               struct check_connected_options opt = CHECK_CONNECTED_INIT;
+
+               if (filter_options.choice)
+                       /*
+                        * Since a filter is specified, objects indirectly
+                        * referenced by refs are allowed to be absent.
+                        */
+                       opt.check_refs_are_promisor_objects_only = 1;
+
                rm = ref_map;
-               if (check_connected(iterate_ref_map, &rm, NULL)) {
+               if (check_connected(iterate_ref_map, &rm, &opt)) {
                        rc = error(_("%s did not send all necessary objects\n"), url);
                        goto abort;
                }