Merge branch 'jt/promisor-remote-fetch-tweak'
Remove error detection from a function that fetches from promisor remotes, and make it die when such a fetch fails to bring all the requested objects, to give an early failure to various operations. * jt/promisor-remote-fetch-tweak: promisor-remote: die upon failing fetch promisor-remote: remove a return value
This commit is contained in:
commit
a2e618cb0f
@ -1599,10 +1599,6 @@ static int do_oid_object_info_extended(struct repository *r,
|
|||||||
if (fetch_if_missing && repo_has_promisor_remote(r) &&
|
if (fetch_if_missing && repo_has_promisor_remote(r) &&
|
||||||
!already_retried &&
|
!already_retried &&
|
||||||
!(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
|
!(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
|
||||||
/*
|
|
||||||
* TODO Investigate checking promisor_remote_get_direct()
|
|
||||||
* TODO return value and stopping on error here.
|
|
||||||
*/
|
|
||||||
promisor_remote_get_direct(r, real, 1);
|
promisor_remote_get_direct(r, real, 1);
|
||||||
already_retried = 1;
|
already_retried = 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
#include "strvec.h"
|
#include "strvec.h"
|
||||||
|
#include "packfile.h"
|
||||||
|
|
||||||
struct promisor_remote_config {
|
struct promisor_remote_config {
|
||||||
struct promisor_remote *promisors;
|
struct promisor_remote *promisors;
|
||||||
@ -230,7 +231,7 @@ static int remove_fetched_oids(struct repository *repo,
|
|||||||
return remaining_nr;
|
return remaining_nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int promisor_remote_get_direct(struct repository *repo,
|
void promisor_remote_get_direct(struct repository *repo,
|
||||||
const struct object_id *oids,
|
const struct object_id *oids,
|
||||||
int oid_nr)
|
int oid_nr)
|
||||||
{
|
{
|
||||||
@ -238,10 +239,10 @@ int promisor_remote_get_direct(struct repository *repo,
|
|||||||
struct object_id *remaining_oids = (struct object_id *)oids;
|
struct object_id *remaining_oids = (struct object_id *)oids;
|
||||||
int remaining_nr = oid_nr;
|
int remaining_nr = oid_nr;
|
||||||
int to_free = 0;
|
int to_free = 0;
|
||||||
int res = -1;
|
int i;
|
||||||
|
|
||||||
if (oid_nr == 0)
|
if (oid_nr == 0)
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
promisor_remote_init(repo);
|
promisor_remote_init(repo);
|
||||||
|
|
||||||
@ -256,12 +257,16 @@ int promisor_remote_get_direct(struct repository *repo,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = 0;
|
goto all_fetched;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < remaining_nr; i++) {
|
||||||
|
if (is_promisor_object(&remaining_oids[i]))
|
||||||
|
die(_("could not fetch %s from promisor remote"),
|
||||||
|
oid_to_hex(&remaining_oids[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
all_fetched:
|
||||||
if (to_free)
|
if (to_free)
|
||||||
free(remaining_oids);
|
free(remaining_oids);
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,11 @@ static inline int has_promisor_remote(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetches all requested objects from all promisor remotes, trying them one at
|
* Fetches all requested objects from all promisor remotes, trying them one at
|
||||||
* a time until all objects are fetched. Returns 0 upon success, and non-zero
|
* a time until all objects are fetched.
|
||||||
* otherwise.
|
|
||||||
*
|
*
|
||||||
* If oid_nr is 0, this function returns 0 (success) immediately.
|
* If oid_nr is 0, this function returns immediately.
|
||||||
*/
|
*/
|
||||||
int promisor_remote_get_direct(struct repository *repo,
|
void promisor_remote_get_direct(struct repository *repo,
|
||||||
const struct object_id *oids,
|
const struct object_id *oids,
|
||||||
int oid_nr);
|
int oid_nr);
|
||||||
|
|
||||||
|
@ -215,6 +215,20 @@ test_expect_success 'fetching of missing objects' '
|
|||||||
grep "$HASH" out
|
grep "$HASH" out
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'fetching of a promised object that promisor remote no longer has' '
|
||||||
|
rm -f err &&
|
||||||
|
test_create_repo unreliable-server &&
|
||||||
|
git -C unreliable-server config uploadpack.allowanysha1inwant 1 &&
|
||||||
|
git -C unreliable-server config uploadpack.allowfilter 1 &&
|
||||||
|
test_commit -C unreliable-server foo &&
|
||||||
|
|
||||||
|
git clone --filter=blob:none --no-checkout "file://$(pwd)/unreliable-server" unreliable-client &&
|
||||||
|
|
||||||
|
rm -rf unreliable-server/.git/objects/* &&
|
||||||
|
test_must_fail git -C unreliable-client checkout HEAD 2>err &&
|
||||||
|
grep "could not fetch.*from promisor remote" err
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'fetching of missing objects works with ref-in-want enabled' '
|
test_expect_success 'fetching of missing objects works with ref-in-want enabled' '
|
||||||
# ref-in-want requires protocol version 2
|
# ref-in-want requires protocol version 2
|
||||||
git -C server config protocol.version 2 &&
|
git -C server config protocol.version 2 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user