Skip to content

Commit 007d7af

Browse files
committed
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 2308984 commit 007d7af

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

scalar.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,25 @@ static void setup_enlistment_directory(int argc, const char **argv,
101101
setup_git_directory();
102102
}
103103

104+
static int git_retries = 3;
105+
104106
static int run_git(const char *arg, ...)
105107
{
106108
struct strvec argv = STRVEC_INIT;
107109
va_list args;
108110
const char *p;
109-
int res;
111+
int res, attempts;
110112

111113
va_start(args, arg);
112114
strvec_push(&argv, arg);
113115
while ((p = va_arg(args, const char *)))
114116
strvec_push(&argv, p);
115117
va_end(args);
116118

117-
res = run_command_v_opt(argv.v, RUN_GIT_CMD);
119+
for (attempts = 0, res = 1;
120+
res && attempts < git_retries;
121+
attempts++)
122+
res = run_command_v_opt(argv.v, RUN_GIT_CMD);
118123

119124
strvec_clear(&argv);
120125
return res;

0 commit comments

Comments
 (0)