Skip to content

Commit 8fb3945

Browse files
committed
Merge branch 'jt/connectivity-check-optim-in-partial-clone'
Unneeded connectivity check is now disabled in a partial clone when fetching into it. * jt/connectivity-check-optim-in-partial-clone: fetch: forgo full connectivity check if --filter connected: verify promisor-ness of partial clone
2 parents 09e4840 + 2df1aa2 commit 8fb3945

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

builtin/clone.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static void update_remote_refs(const struct ref *refs,
673673
const char *msg,
674674
struct transport *transport,
675675
int check_connectivity,
676-
int check_refs_only)
676+
int check_refs_are_promisor_objects_only)
677677
{
678678
const struct ref *rm = mapped_refs;
679679

@@ -682,7 +682,8 @@ static void update_remote_refs(const struct ref *refs,
682682

683683
opt.transport = transport;
684684
opt.progress = transport->progress;
685-
opt.check_refs_only = !!check_refs_only;
685+
opt.check_refs_are_promisor_objects_only =
686+
!!check_refs_are_promisor_objects_only;
686687

687688
if (check_connected(iterate_ref_map, &rm, &opt))
688689
die(_("remote did not send all necessary objects"));

builtin/fetch.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,17 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
906906
url = xstrdup("foreign");
907907

908908
if (!connectivity_checked) {
909+
struct check_connected_options opt = CHECK_CONNECTED_INIT;
910+
911+
if (filter_options.choice)
912+
/*
913+
* Since a filter is specified, objects indirectly
914+
* referenced by refs are allowed to be absent.
915+
*/
916+
opt.check_refs_are_promisor_objects_only = 1;
917+
909918
rm = ref_map;
910-
if (check_connected(iterate_ref_map, &rm, NULL)) {
919+
if (check_connected(iterate_ref_map, &rm, &opt)) {
911920
rc = error(_("%s did not send all necessary objects\n"), url);
912921
goto abort;
913922
}

connected.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,28 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
5252
strbuf_release(&idx_file);
5353
}
5454

55-
if (opt->check_refs_only) {
55+
if (opt->check_refs_are_promisor_objects_only) {
5656
/*
5757
* For partial clones, we don't want to have to do a regular
5858
* connectivity check because we have to enumerate and exclude
5959
* all promisor objects (slow), and then the connectivity check
6060
* itself becomes a no-op because in a partial clone every
6161
* object is a promisor object. Instead, just make sure we
62-
* received the objects pointed to by each wanted ref.
62+
* received, in a promisor packfile, the objects pointed to by
63+
* each wanted ref.
6364
*/
6465
do {
65-
if (!repo_has_object_file_with_flags(the_repository, &oid,
66-
OBJECT_INFO_SKIP_FETCH_OBJECT))
67-
return 1;
66+
struct packed_git *p;
67+
68+
for (p = get_all_packs(the_repository); p; p = p->next) {
69+
if (!p->pack_promisor)
70+
continue;
71+
if (find_pack_entry_one(oid.hash, p))
72+
goto promisor_pack_found;
73+
}
74+
return 1;
75+
promisor_pack_found:
76+
;
6877
} while (!fn(cb_data, &oid));
6978
return 0;
7079
}

connected.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ struct check_connected_options {
4848
unsigned is_deepening_fetch : 1;
4949

5050
/*
51-
* If non-zero, only check the top-level objects referenced by the
52-
* wanted refs (passed in as cb_data). This is useful for partial
53-
* clones, where enumerating and excluding all promisor objects is very
54-
* slow and the commit-walk itself becomes a no-op.
51+
* If non-zero, only check that the top-level objects referenced by the
52+
* wanted refs (passed in as cb_data) are promisor objects. This is
53+
* useful for partial clones, where enumerating and excluding all
54+
* promisor objects is very slow and the commit-walk itself becomes a
55+
* no-op.
5556
*/
56-
unsigned check_refs_only : 1;
57+
unsigned check_refs_are_promisor_objects_only : 1;
5758
};
5859

5960
#define CHECK_CONNECTED_INIT { 0 }

0 commit comments

Comments
 (0)