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 authored and vdye committed Jul 19, 2023
1 parent d098c27 commit 888e8fc
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 @@ -167,6 +167,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 @@ -208,6 +209,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 @@ -217,10 +223,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 888e8fc

Please sign in to comment.