Skip to content

Commit 5b68974

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 38b92fd commit 5b68974

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
@@ -172,6 +172,7 @@ static int set_recommended_config(int reconfigure)
172172
{ "core.safeCRLF", "false" },
173173
{ "fetch.showForcedUpdates", "false" },
174174
{ "pack.usePathWalk", "true" },
175+
{ "core.configWriteLockTimeoutMS", "150" },
175176
{ NULL, NULL },
176177
};
177178
int i;
@@ -219,6 +220,11 @@ static int set_recommended_config(int reconfigure)
219220
*/
220221
static int toggle_maintenance(int enable)
221222
{
223+
unsigned long ul;
224+
225+
if (repo_config_get_ulong(the_repository, "core.configWriteLockTimeoutMS", &ul))
226+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
227+
222228
return run_git("maintenance",
223229
enable ? "start" : "unregister",
224230
enable ? NULL : "--force",
@@ -228,10 +234,14 @@ static int toggle_maintenance(int enable)
228234
static int add_or_remove_enlistment(int add)
229235
{
230236
int res;
237+
unsigned long ul;
231238

232239
if (!the_repository->worktree)
233240
die(_("Scalar enlistments require a worktree"));
234241

242+
if (repo_config_get_ulong(the_repository, "core.configWriteLockTimeoutMS", &ul))
243+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
244+
235245
res = run_git("config", "--global", "--get", "--fixed-value",
236246
"scalar.repo", the_repository->worktree, NULL);
237247

0 commit comments

Comments
 (0)