Merge branch 'ps/gc-stale-lock-warning'
Give a bit of advice/hint message when "git maintenance" stops finding a lock file left by another instance that still is potentially running. * ps/gc-stale-lock-warning: t7900: fix host-dependent behaviour when testing git-maintenance(1) builtin/gc: provide hint when maintenance hits a stale schedule lock
This commit is contained in:
11
builtin/gc.c
11
builtin/gc.c
@ -2890,8 +2890,17 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,
|
||||
char *lock_path = xstrfmt("%s/schedule", the_repository->objects->odb->path);
|
||||
|
||||
if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
|
||||
if (errno == EEXIST)
|
||||
error(_("unable to create '%s.lock': %s.\n\n"
|
||||
"Another scheduled git-maintenance(1) process seems to be running in this\n"
|
||||
"repository. Please make sure no other maintenance processes are running and\n"
|
||||
"then try again. If it still fails, a git-maintenance(1) process may have\n"
|
||||
"crashed in this repository earlier: remove the file manually to continue."),
|
||||
absolute_path(lock_path), strerror(errno));
|
||||
else
|
||||
error_errno(_("cannot acquire lock for scheduled background maintenance"));
|
||||
free(lock_path);
|
||||
return error(_("another process is scheduling background maintenance"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 1; i < ARRAY_SIZE(scheduler_fn); i++) {
|
||||
|
@ -1011,4 +1011,17 @@ test_expect_success 'repacking loose objects is quiet' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'maintenance aborts with existing lock file' '
|
||||
test_when_finished "rm -rf repo script" &&
|
||||
mkdir script &&
|
||||
write_script script/systemctl <<-\EOF &&
|
||||
true
|
||||
EOF
|
||||
|
||||
git init repo &&
|
||||
: >repo/.git/objects/schedule.lock &&
|
||||
test_must_fail env PATH="$PWD/script:$PATH" git -C repo maintenance start --scheduler=systemd 2>err &&
|
||||
test_grep "Another scheduled git-maintenance(1) process seems to be running" err
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user