Git fork

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

+23 -1
+10 -1
builtin/gc.c
··· 2890 2890 char *lock_path = xstrfmt("%s/schedule", the_repository->objects->odb->path); 2891 2891 2892 2892 if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) { 2893 + if (errno == EEXIST) 2894 + error(_("unable to create '%s.lock': %s.\n\n" 2895 + "Another scheduled git-maintenance(1) process seems to be running in this\n" 2896 + "repository. Please make sure no other maintenance processes are running and\n" 2897 + "then try again. If it still fails, a git-maintenance(1) process may have\n" 2898 + "crashed in this repository earlier: remove the file manually to continue."), 2899 + absolute_path(lock_path), strerror(errno)); 2900 + else 2901 + error_errno(_("cannot acquire lock for scheduled background maintenance")); 2893 2902 free(lock_path); 2894 - return error(_("another process is scheduling background maintenance")); 2903 + return -1; 2895 2904 } 2896 2905 2897 2906 for (i = 1; i < ARRAY_SIZE(scheduler_fn); i++) {
+13
t/t7900-maintenance.sh
··· 1011 1011 ) 1012 1012 ' 1013 1013 1014 + test_expect_success 'maintenance aborts with existing lock file' ' 1015 + test_when_finished "rm -rf repo script" && 1016 + mkdir script && 1017 + write_script script/systemctl <<-\EOF && 1018 + true 1019 + EOF 1020 + 1021 + git init repo && 1022 + : >repo/.git/objects/schedule.lock && 1023 + test_must_fail env PATH="$PWD/script:$PATH" git -C repo maintenance start --scheduler=systemd 2>err && 1024 + test_grep "Another scheduled git-maintenance(1) process seems to be running" err 1025 + ' 1026 + 1014 1027 test_done