summaryrefslogtreecommitdiff
path: root/connected.c
diff options
context:
space:
mode:
Diffstat (limited to 'connected.c')
-rw-r--r--connected.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/connected.c b/connected.c
index 1bba888eff..3135b71e19 100644
--- a/connected.c
+++ b/connected.c
@@ -1,9 +1,11 @@
#include "cache.h"
+#include "object-store.h"
#include "run-command.h"
#include "sigchain.h"
#include "connected.h"
#include "transport.h"
#include "packfile.h"
+#include "promisor-remote.h"
/*
* If we feed all the commits we want to verify to this command
@@ -27,6 +29,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
struct packed_git *new_pack = NULL;
struct transport *transport;
size_t base_len;
+ const unsigned hexsz = the_hash_algo->hexsz;
if (!opt)
opt = &defaults;
@@ -49,6 +52,41 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
strbuf_release(&idx_file);
}
+ if (has_promisor_remote()) {
+ /*
+ * For partial clones, we don't want to have to do a regular
+ * connectivity check because we have to enumerate and exclude
+ * all promisor objects (slow), and then the connectivity check
+ * itself becomes a no-op because in a partial clone every
+ * object is a promisor object. Instead, just make sure we
+ * received, in a promisor packfile, the objects pointed to by
+ * each wanted ref.
+ *
+ * Before checking for promisor packs, be sure we have the
+ * latest pack-files loaded into memory.
+ */
+ reprepare_packed_git(the_repository);
+ do {
+ struct packed_git *p;
+
+ for (p = get_all_packs(the_repository); p; p = p->next) {
+ if (!p->pack_promisor)
+ continue;
+ if (find_pack_entry_one(oid.hash, p))
+ goto promisor_pack_found;
+ }
+ /*
+ * Fallback to rev-list with oid and the rest of the
+ * object IDs provided by fn.
+ */
+ goto no_promisor_pack_found;
+promisor_pack_found:
+ ;
+ } while (!fn(cb_data, &oid));
+ return 0;
+ }
+
+no_promisor_pack_found:
if (opt->shallow_file) {
argv_array_push(&rev_list.args, "--shallow-file");
argv_array_push(&rev_list.args, opt->shallow_file);
@@ -56,13 +94,14 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
argv_array_push(&rev_list.args,"rev-list");
argv_array_push(&rev_list.args, "--objects");
argv_array_push(&rev_list.args, "--stdin");
- if (repository_format_partial_clone)
+ if (has_promisor_remote())
argv_array_push(&rev_list.args, "--exclude-promisor-objects");
if (!opt->is_deepening_fetch) {
argv_array_push(&rev_list.args, "--not");
argv_array_push(&rev_list.args, "--all");
}
argv_array_push(&rev_list.args, "--quiet");
+ argv_array_push(&rev_list.args, "--alternate-refs");
if (opt->progress)
argv_array_pushf(&rev_list.args, "--progress=%s",
_("Checking connectivity"));
@@ -81,7 +120,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
sigchain_push(SIGPIPE, SIG_IGN);
- commit[GIT_SHA1_HEXSZ] = '\n';
+ commit[hexsz] = '\n';
do {
/*
* If index-pack already checked that:
@@ -94,8 +133,8 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
if (new_pack && find_pack_entry_one(oid.hash, new_pack))
continue;
- memcpy(commit, oid_to_hex(&oid), GIT_SHA1_HEXSZ);
- if (write_in_full(rev_list.in, commit, GIT_SHA1_HEXSZ + 1) < 0) {
+ memcpy(commit, oid_to_hex(&oid), hexsz);
+ if (write_in_full(rev_list.in, commit, hexsz + 1) < 0) {
if (errno != EPIPE && errno != EINVAL)
error_errno(_("failed write to rev-list"));
err = -1;