Skip to content

Commit 61ccf7f

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 e5f4e63 commit 61ccf7f

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;
@@ -218,6 +219,11 @@ static int set_recommended_config(int reconfigure)
218219
*/
219220
static int toggle_maintenance(int enable)
220221
{
222+
unsigned long ul;
223+
224+
if (repo_config_get_ulong(the_repository, "core.configWriteLockTimeoutMS", &ul))
225+
git_config_push_parameter("core.configWriteLockTimeoutMS=150");
226+
221227
return run_git("maintenance",
222228
enable ? "start" : "unregister",
223229
enable ? NULL : "--force",
@@ -227,10 +233,14 @@ static int toggle_maintenance(int enable)
227233
static int add_or_remove_enlistment(int add)
228234
{
229235
int res;
236+
unsigned long ul;
230237

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

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

0 commit comments

Comments
 (0)