Skip to content

Commit 2d2de8f

Browse files
derrickstoleedscho
authored andcommitted
scalar: add retry logic to run_git()
Use a fixed 3 tries total to see how that increases our chances of success for subcommands such as 'git fetch'. Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
1 parent be45bd5 commit 2d2de8f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scalar.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,25 @@ static void setup_enlistment_directory(int argc, const char **argv,
7070
strbuf_release(&path);
7171
}
7272

73+
static int git_retries = 3;
74+
7375
static int run_git(const char *arg, ...)
7476
{
7577
struct strvec argv = STRVEC_INIT;
7678
va_list args;
7779
const char *p;
78-
int res;
80+
int res, attempts;
7981

8082
va_start(args, arg);
8183
strvec_push(&argv, arg);
8284
while ((p = va_arg(args, const char *)))
8385
strvec_push(&argv, p);
8486
va_end(args);
8587

86-
res = run_command_v_opt(argv.v, RUN_GIT_CMD);
88+
for (attempts = 0, res = 1;
89+
res && attempts < git_retries;
90+
attempts++)
91+
res = run_command_v_opt(argv.v, RUN_GIT_CMD);
8792

8893
strvec_clear(&argv);
8994
return res;

0 commit comments

Comments
 (0)