Skip to content

Commit

Permalink
scalar: add retry logic to run_git()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
derrickstolee authored and dscho committed Sep 16, 2022
1 parent be45bd5 commit 2d2de8f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,25 @@ static void setup_enlistment_directory(int argc, const char **argv,
strbuf_release(&path);
}

static int git_retries = 3;

static int run_git(const char *arg, ...)
{
struct strvec argv = STRVEC_INIT;
va_list args;
const char *p;
int res;
int res, attempts;

va_start(args, arg);
strvec_push(&argv, arg);
while ((p = va_arg(args, const char *)))
strvec_push(&argv, p);
va_end(args);

res = run_command_v_opt(argv.v, RUN_GIT_CMD);
for (attempts = 0, res = 1;
res && attempts < git_retries;
attempts++)
res = run_command_v_opt(argv.v, RUN_GIT_CMD);

strvec_clear(&argv);
return res;
Expand Down

0 comments on commit 2d2de8f

Please sign in to comment.