Skip to content

Commit 95e833e

Browse files
spkrkagitster
authored andcommitted
fetch: pass transport to post-fetch connectivity check
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>
1 parent 6a4418c commit 95e833e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

builtin/fetch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,7 @@ N_("it took %.2f seconds to check forced updates; you can use\n"
12131213
"to avoid this check\n");
12141214

12151215
static int store_updated_refs(struct display_state *display_state,
1216+
struct transport *transport,
12161217
int connectivity_checked,
12171218
struct ref_transaction *transaction, struct ref *ref_map,
12181219
struct fetch_head *fetch_head,
@@ -1228,6 +1229,7 @@ static int store_updated_refs(struct display_state *display_state,
12281229
if (!connectivity_checked) {
12291230
struct check_connected_options opt = CHECK_CONNECTED_INIT;
12301231

1232+
opt.transport = transport;
12311233
opt.exclude_hidden_refs_section = "fetch";
12321234
rm = ref_map;
12331235
if (check_connected(iterate_ref_map, &rm, &opt)) {
@@ -1432,7 +1434,7 @@ static int fetch_and_consume_refs(struct display_state *display_state,
14321434
}
14331435

14341436
trace2_region_enter("fetch", "consume_refs", the_repository);
1435-
ret = store_updated_refs(display_state, connectivity_checked,
1437+
ret = store_updated_refs(display_state, transport, connectivity_checked,
14361438
transaction, ref_map, fetch_head, config,
14371439
display_array);
14381440
trace2_region_leave("fetch", "consume_refs", the_repository);

0 commit comments

Comments
 (0)