]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: pass transport to post-fetch connectivity check
authorKristofer Karlsson <krka@spotify.com>
Sun, 24 May 2026 12:28:12 +0000 (12:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 24 May 2026 12:54:12 +0000 (21:54 +0900)
When fetching with a transport that sets `self_contained_and_connected`
(as index-pack does for self-contained packs), check_connected() can
use find_pack_entry_one() to skip connectivity verification for refs
whose objects exist in the new pack. This avoids sending those OIDs to
the rev-list child process.

However, store_updated_refs() never passed the transport to
check_connected(), so opt.transport was always NULL and this
optimization was dead code for post-fetch connectivity checks.

Thread the transport parameter through store_updated_refs() and set
opt.transport so that check_connected() can take advantage of
self-contained packs.

On a large repository (2.4M commits, 374K files, 10.9K local refs),
fetching 200 new commits:

  Before: rev-list connectivity check  22s,  total fetch  36s
  After:  rev-list connectivity check   5s,  total fetch  14s

The remaining 5s is spent verifying refs not contained in the new pack.

Signed-off-by: Kristofer Karlsson <krka@spotify.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c

index a22c3194670e9a67765d1ae26b423ed65db9ab41..647fd1c30c6415491c9a472feb103eaa4307fb31 100644 (file)
@@ -1213,6 +1213,7 @@ N_("it took %.2f seconds to check forced updates; you can use\n"
    "to avoid this check\n");
 
 static int store_updated_refs(struct display_state *display_state,
+                             struct transport *transport,
                              int connectivity_checked,
                              struct ref_transaction *transaction, struct ref *ref_map,
                              struct fetch_head *fetch_head,
@@ -1228,6 +1229,7 @@ static int store_updated_refs(struct display_state *display_state,
        if (!connectivity_checked) {
                struct check_connected_options opt = CHECK_CONNECTED_INIT;
 
+               opt.transport = transport;
                opt.exclude_hidden_refs_section = "fetch";
                rm = ref_map;
                if (check_connected(iterate_ref_map, &rm, &opt)) {
@@ -1432,7 +1434,7 @@ static int fetch_and_consume_refs(struct display_state *display_state,
        }
 
        trace2_region_enter("fetch", "consume_refs", the_repository);
-       ret = store_updated_refs(display_state, connectivity_checked,
+       ret = store_updated_refs(display_state, transport, connectivity_checked,
                                 transaction, ref_map, fetch_head, config,
                                 display_array);
        trace2_region_leave("fetch", "consume_refs", the_repository);