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 <johasc@microsoft.com>
This commit is contained in:
Johannes Schindelin 2021-05-18 23:22:56 +02:00 коммит произвёл Victoria Dye
Родитель 15d3cfc67d
Коммит 3d6a21788d
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -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;
@ -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",
@ -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);