Skip to content

Commit 2f6565c

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 <[email protected]>
1 parent 60e6b64 commit 2f6565c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

contrib/scalar/scalar.c

Lines changed: 7 additions & 2 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;

0 commit comments

Comments
 (0)