Skip to content

Commit fe69bd7

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 <johasc@microsoft.com>
1 parent c5805b8 commit fe69bd7

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
@@ -167,6 +167,7 @@ static int set_recommended_config(int reconfigure)
167167
{ "core.autoCRLF", "false" },
168168
{ "core.safeCRLF", "false" },
169169
{ "fetch.showForcedUpdates", "false" },
170+
{ "core.configWriteLockTimeoutMS", "150" },
170171
{ NULL, NULL },
171172
};
172173
int i;
@@ -208,6 +209,11 @@ static int set_recommended_config(int reconfigure)
208209

209210
static int toggle_maintenance(int enable)
210211
{
212+
unsigned long ul;
213+
214+
if (git_config_get_ulong("core.configWriteLockTimeoutMS", &ul))
215+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
216+
211217
return run_git("maintenance",
212218
enable ? "start" : "unregister",
213219
enable ? NULL : "--force",
@@ -217,10 +223,14 @@ static int toggle_maintenance(int enable)
217223
static int add_or_remove_enlistment(int add)
218224
{
219225
int res;
226+
unsigned long ul;
220227

221228
if (!the_repository->worktree)
222229
die(_("Scalar enlistments require a worktree"));
223230

231+
if (git_config_get_ulong("core.configWriteLockTimeoutMS", &ul))
232+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
233+
224234
res = run_git("config", "--global", "--get", "--fixed-value",
225235
"scalar.repo", the_repository->worktree, NULL);
226236

0 commit comments

Comments
 (0)