Skip to content

Commit b8f49b5

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 <johannes.schindelin@gmx.de>
1 parent 2762265 commit b8f49b5

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎Documentation/scalar.adoc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ status.aheadBehind=false::
347347
message that can be disabled by disabling the `advice.statusAheadBehind`
348348
config.
349349
350+
core.configWriteLockTimeoutMS::
351+
Sets a timeout to work gracefully around Git config write contention.
352+
350353
The following settings are different based on which platform is in use:
351354
352355
core.untrackedCache=(true|false)::

‎scalar.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static int set_recommended_config(int reconfigure)
141141
{ "commitGraph.changedPaths", "true" },
142142
{ "commitGraph.generationVersion", "1" },
143143
{ "core.autoCRLF", "false" },
144+
{ "core.configWriteLockTimeoutMS", "150" },
144145
{ "core.logAllRefUpdates", "true" },
145146
{ "core.safeCRLF", "false" },
146147
{ "credential.https://dev.azure.com.useHttpPath", "true" },
@@ -228,6 +229,11 @@ static int set_recommended_config(int reconfigure)
228229
*/
229230
static int toggle_maintenance(int enable)
230231
{
232+
unsigned long ul;
233+
234+
if (repo_config_get_ulong(the_repository, "core.configWriteLockTimeoutMS", &ul))
235+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
236+
231237
return run_git("maintenance",
232238
enable ? "start" : "unregister",
233239
enable ? NULL : "--force",
@@ -237,10 +243,14 @@ static int toggle_maintenance(int enable)
237243
static int add_or_remove_enlistment(int add)
238244
{
239245
int res;
246+
unsigned long ul;
240247

241248
if (!the_repository->worktree)
242249
die(_("Scalar enlistments require a worktree"));
243250

251+
if (repo_config_get_ulong(the_repository, "core.configWriteLockTimeoutMS", &ul))
252+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
253+
244254
res = run_git("config", "--global", "--get", "--fixed-value",
245255
"scalar.repo", the_repository->worktree, NULL);
246256

0 commit comments

Comments
 (0)