Merge branch 'jt/connectivity-check-optim-in-partial-clone'

Simplify the commit ancestry connectedness check in a partial clone
repository in which "promised" objects are assumed to be obtainable
lazily on-demand from promisor remote repositories.

* jt/connectivity-check-optim-in-partial-clone:
  connected: always use partial clone optimization
This commit is contained in:
Junio C Hamano
2020-04-22 13:42:43 -07:00
4 changed files with 9 additions and 23 deletions

View File

@ -676,8 +676,7 @@ static void update_remote_refs(const struct ref *refs,
const char *branch_top, const char *branch_top,
const char *msg, const char *msg,
struct transport *transport, struct transport *transport,
int check_connectivity, int check_connectivity)
int check_refs_are_promisor_objects_only)
{ {
const struct ref *rm = mapped_refs; const struct ref *rm = mapped_refs;
@ -686,8 +685,6 @@ static void update_remote_refs(const struct ref *refs,
opt.transport = transport; opt.transport = transport;
opt.progress = transport->progress; opt.progress = transport->progress;
opt.check_refs_are_promisor_objects_only =
!!check_refs_are_promisor_objects_only;
if (check_connected(iterate_ref_map, &rm, &opt)) if (check_connected(iterate_ref_map, &rm, &opt))
die(_("remote did not send all necessary objects")); die(_("remote did not send all necessary objects"));
@ -1282,7 +1279,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
update_remote_refs(refs, mapped_refs, remote_head_points_at, update_remote_refs(refs, mapped_refs, remote_head_points_at,
branch_top.buf, reflog_msg.buf, transport, branch_top.buf, reflog_msg.buf, transport,
!is_local, filter_options.choice); !is_local);
update_head(our_head_points_at, remote_head, reflog_msg.buf); update_head(our_head_points_at, remote_head, reflog_msg.buf);

View File

@ -908,13 +908,6 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
if (!connectivity_checked) { if (!connectivity_checked) {
struct check_connected_options opt = CHECK_CONNECTED_INIT; 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; rm = ref_map;
if (check_connected(iterate_ref_map, &rm, &opt)) { if (check_connected(iterate_ref_map, &rm, &opt)) {
rc = error(_("%s did not send all necessary objects\n"), url); rc = error(_("%s did not send all necessary objects\n"), url);

View File

@ -52,7 +52,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
strbuf_release(&idx_file); strbuf_release(&idx_file);
} }
if (opt->check_refs_are_promisor_objects_only) { if (has_promisor_remote()) {
/* /*
* For partial clones, we don't want to have to do a regular * For partial clones, we don't want to have to do a regular
* connectivity check because we have to enumerate and exclude * connectivity check because we have to enumerate and exclude
@ -75,13 +75,18 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
if (find_pack_entry_one(oid.hash, p)) if (find_pack_entry_one(oid.hash, p))
goto promisor_pack_found; goto promisor_pack_found;
} }
return 1; /*
* Fallback to rev-list with oid and the rest of the
* object IDs provided by fn.
*/
goto no_promisor_pack_found;
promisor_pack_found: promisor_pack_found:
; ;
} while (!fn(cb_data, &oid)); } while (!fn(cb_data, &oid));
return 0; return 0;
} }
no_promisor_pack_found:
if (opt->shallow_file) { if (opt->shallow_file) {
argv_array_push(&rev_list.args, "--shallow-file"); argv_array_push(&rev_list.args, "--shallow-file");
argv_array_push(&rev_list.args, opt->shallow_file); argv_array_push(&rev_list.args, opt->shallow_file);

View File

@ -46,15 +46,6 @@ struct check_connected_options {
* during a fetch. * during a fetch.
*/ */
unsigned is_deepening_fetch : 1; unsigned is_deepening_fetch : 1;
/*
* If non-zero, only check that the top-level objects referenced by the
* wanted refs (passed in as cb_data) are promisor objects. This is
* useful for partial clones, where enumerating and excluding all
* promisor objects is very slow and the commit-walk itself becomes a
* no-op.
*/
unsigned check_refs_are_promisor_objects_only : 1;
}; };
#define CHECK_CONNECTED_INIT { 0 } #define CHECK_CONNECTED_INIT { 0 }