Skip to content

Commit 469b549

Browse files
committed
scalar: set the config write-lock timeout to 150ms
By default, Git fails immediately when locking a config file for writing fails due to an existing lock. With this change, Scalar-registered repositories will fall back to trying a couple times within a 150ms timeout. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 1526f65 commit 469b549

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

scalar.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ static int set_recommended_config(int reconfigure)
171171
{ "core.safeCRLF", "false" },
172172
{ "fetch.showForcedUpdates", "false" },
173173
{ "pack.usePathWalk", "true" },
174+
{ "core.configWriteLockTimeoutMS", "150" },
174175
{ NULL, NULL },
175176
};
176177
int i;
@@ -212,6 +213,11 @@ static int set_recommended_config(int reconfigure)
212213

213214
static int toggle_maintenance(int enable)
214215
{
216+
unsigned long ul;
217+
218+
if (git_config_get_ulong("core.configWriteLockTimeoutMS", &ul))
219+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
220+
215221
return run_git("maintenance",
216222
enable ? "start" : "unregister",
217223
enable ? NULL : "--force",
@@ -221,10 +227,14 @@ static int toggle_maintenance(int enable)
221227
static int add_or_remove_enlistment(int add)
222228
{
223229
int res;
230+
unsigned long ul;
224231

225232
if (!the_repository->worktree)
226233
die(_("Scalar enlistments require a worktree"));
227234

235+
if (git_config_get_ulong("core.configWriteLockTimeoutMS", &ul))
236+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
237+
228238
res = run_git("config", "--global", "--get", "--fixed-value",
229239
"scalar.repo", the_repository->worktree, NULL);
230240

0 commit comments

Comments
 (0)