Skip to content

Commit

Permalink
scalar: set the config write-lock timeout to 150ms
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho committed Sep 18, 2024
1 parent 6bb3782 commit 6816304
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ static int set_recommended_config(int reconfigure)
{ "core.autoCRLF", "false" },
{ "core.safeCRLF", "false" },
{ "fetch.showForcedUpdates", "false" },
{ "core.configWriteLockTimeoutMS", "150" },
{ NULL, NULL },
};
int i;
Expand Down Expand Up @@ -211,6 +212,11 @@ static int set_recommended_config(int reconfigure)

static int toggle_maintenance(int enable)
{
unsigned long ul;

if (git_config_get_ulong("core.configWriteLockTimeoutMS", &ul))
git_config_push_parameter("core.configWriteLockTimeoutMS=150");

return run_git("maintenance",
enable ? "start" : "unregister",
enable ? NULL : "--force",
Expand All @@ -220,10 +226,14 @@ static int toggle_maintenance(int enable)
static int add_or_remove_enlistment(int add)
{
int res;
unsigned long ul;

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

if (git_config_get_ulong("core.configWriteLockTimeoutMS", &ul))
git_config_push_parameter("core.configWriteLockTimeoutMS=150");

res = run_git("config", "--global", "--get", "--fixed-value",
"scalar.repo", the_repository->worktree, NULL);

Expand Down

0 comments on commit 6816304

Please sign in to comment.