Use promisor_remote_get_direct() and has_promisor_remote()

Instead of using the repository_format_partial_clone global
and fetch_objects() directly, let's use has_promisor_remote()
and promisor_remote_get_direct().

This way all the configured promisor remotes will be taken
into account, not only the one specified by
extensions.partialClone.

Also when cloning or fetching using a partial clone filter,
remote.origin.promisor will be set to "true" instead of
setting extensions.partialClone to "origin". This makes it
possible to use many promisor remote just by fetching from
them.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Christian Couder
2019-06-25 15:40:31 +02:00
committed by Junio C Hamano
parent faf2abf496
commit b14ed5adaf
14 changed files with 56 additions and 47 deletions

View File

@ -30,8 +30,8 @@
#include "mergesort.h"
#include "quote.h"
#include "packfile.h"
#include "fetch-object.h"
#include "object-store.h"
#include "promisor-remote.h"
/* The maximum size for an object header. */
#define MAX_HEADER_LEN 32
@ -1377,16 +1377,17 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,
}
/* Check if it is a missing object */
if (fetch_if_missing && repository_format_partial_clone &&
if (fetch_if_missing && has_promisor_remote() &&
!already_retried && r == the_repository &&
!(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
/*
* TODO Investigate checking fetch_object() return
* TODO value and stopping on error here.
* TODO Pass a repository struct through fetch_object,
* such that arbitrary repositories work.
* TODO Investigate checking promisor_remote_get_direct()
* TODO return value and stopping on error here.
* TODO Pass a repository struct through
* promisor_remote_get_direct(), such that arbitrary
* repositories work.
*/
fetch_objects(repository_format_partial_clone, real, 1);
promisor_remote_get_direct(r, real, 1);
already_retried = 1;
continue;
}