Skip to content

Commit 0978f54

Browse files
committed
Merge pull request git-for-windows#378: Scalar: Fix some flaky tests with retry logic and better GVFS Protocol awareness
I ran the Scalar functional tests at least 10 times before getting a full green build. One of the most common failures was a failure during `scalar clone` with a strange error. Looking at the TRACE2 logs, I found these entries: ``` d0 | main | child_start | | 0.159207 | | | [ch2] class:? argv:[git fetch --quiet origin] d0 | main | child_exit | | 15.823433 | 15.664226 | | [ch2] pid:16571 code:128 d0 | main | error | | | | | Partial clone failed; Trying full clone d0 | main | error | | | | | could not configure for full clone d0 | main | exit | | 15.823775 | | | code:1 d0 | main | atexit | | 15.823790 | | | code:1 ``` This means that the first `git fetch` failed for some reason, and we started running `set_config()` to un-set the partial-clone config options. However, we are not in a partial clone at this state! We are working against Azure Repos. There are two things in this PR that should help: 1. Add retry logic to `run_git()` which will retry the `git fetch` when it fails (also other subcommands). 2. Fix this use of `set_config()` by skipping it if we are using the GVFS Protocol.
2 parents 8f3ebdc + 521a7f3 commit 0978f54

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

contrib/scalar/scalar.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,25 @@ static void setup_enlistment_directory(int argc, const char **argv,
107107
setup_git_directory();
108108
}
109109

110+
static int git_retries = 3;
111+
110112
static int run_git(const char *arg, ...)
111113
{
112114
struct strvec argv = STRVEC_INIT;
113115
va_list args;
114116
const char *p;
115-
int res;
117+
int res, attempts;
116118

117119
va_start(args, arg);
118120
strvec_push(&argv, arg);
119121
while ((p = va_arg(args, const char *)))
120122
strvec_push(&argv, p);
121123
va_end(args);
122124

123-
res = run_command_v_opt(argv.v, RUN_GIT_CMD);
125+
for (attempts = 0, res = 1;
126+
res && attempts < git_retries;
127+
attempts++)
128+
res = run_command_v_opt(argv.v, RUN_GIT_CMD);
124129

125130
strvec_clear(&argv);
126131
return res;
@@ -879,6 +884,7 @@ static int cmd_clone(int argc, const char **argv)
879884
char *cache_key = NULL, *shared_cache_path = NULL;
880885
struct strbuf buf = STRBUF_INIT;
881886
int res;
887+
int gvfs_protocol;
882888

883889
argc = parse_options(argc, argv, NULL, clone_options, clone_usage, 0);
884890

@@ -1006,8 +1012,10 @@ static int cmd_clone(int argc, const char **argv)
10061012
goto cleanup;
10071013
}
10081014

1009-
if (cache_server_url ||
1010-
supports_gvfs_protocol(url, &default_cache_server_url)) {
1015+
gvfs_protocol = cache_server_url ||
1016+
supports_gvfs_protocol(url, &default_cache_server_url);
1017+
1018+
if (gvfs_protocol) {
10111019
if (!cache_server_url)
10121020
cache_server_url = default_cache_server_url;
10131021
if (set_config("core.useGVFSHelper=true") ||
@@ -1042,7 +1050,12 @@ static int cmd_clone(int argc, const char **argv)
10421050
return error(_("could not configure '%s'"), dir);
10431051

10441052
if ((res = run_git("fetch", "--quiet", "origin", NULL))) {
1045-
warning(_("Partial clone failed; Trying full clone"));
1053+
if (gvfs_protocol) {
1054+
res = error(_("failed to prefetch commits and trees"));
1055+
goto cleanup;
1056+
}
1057+
1058+
warning(_("partial clone failed; attempting full clone"));
10461059

10471060
if (set_config("remote.origin.promisor") ||
10481061
set_config("remote.origin.partialCloneFilter")) {

0 commit comments

Comments
 (0)