diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2021-02-23 02:31:07 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-02-23 00:22:45 -0800 |
commit | 26c7974376fad730ba5bc1926afe7d26ba8d91e0 (patch) | |
tree | 554605ecaad0b8f6ec3fb83ee8ddef778dea506f /t | |
parent | The tenth batch (diff) | |
download | tgif-26c7974376fad730ba5bc1926afe7d26ba8d91e0.tar.xz |
maintenance: fix incorrect `maintenance.repo` path with bare repository
The periodic maintenance tasks configured by `git maintenance start`
invoke `git for-each-repo` to run `git maintenance run` on each path
specified by the multi-value global configuration variable
`maintenance.repo`. Because `git for-each-repo` will likely be run
outside of the repositories which require periodic maintenance, it is
mandatory that the repository paths specified by `maintenance.repo` are
absolute.
Unfortunately, however, `git maintenance register` does nothing to
ensure that the paths it assigns to `maintenance.repo` are indeed
absolute, and may in fact -- especially in the case of a bare repository
-- assign a relative path to `maintenance.repo` instead. Fix this
problem by converting all paths to absolute before assigning them to
`maintenance.repo`.
While at it, also fix `git maintenance unregister` to convert paths to
absolute, as well, in order to ensure that it can correctly remove from
`maintenance.repo` a path assigned via `git maintenance register`.
Reported-by: Clement Moyroud <clement.moyroud@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t7900-maintenance.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 286b18db3c..2412d8c5c0 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -632,4 +632,17 @@ test_expect_success 'fails when running outside of a repository' ' nongit test_must_fail git maintenance unregister ' +test_expect_success 'register and unregister bare repo' ' + test_when_finished "git config --global --unset-all maintenance.repo || :" && + test_might_fail git config --global --unset-all maintenance.repo && + git init --bare barerepo && + ( + cd barerepo && + git maintenance register && + git config --get --global --fixed-value maintenance.repo "$(pwd)" && + git maintenance unregister && + test_must_fail git config --global --get-all maintenance.repo + ) +' + test_done |