gc: ignore old gc.log files
PATCH v4 1/1 gc: ignore old gc.log files
Git should never get itself into a state where it refuses to do any maintenance, just because at some point some piece of the maintenance didn't make progress.
In this commit, git learns to ignore gc.log files which are older than (by default) one day old. It also learns about a config, gc.logExpiry to manage this. There is also some cleanup: a successful manual gc, or a warning-free auto gc, will remove any old gc.log files.
It might still happen that manual intervention is required (e.g. because the repo is corrupt), but at the very least it won't be because Git is too dumb to try again.
Automatic gc was intended to make client repositories be self-maintaining. It would be good if automatic gc were also useful to server operators. A server can end up in a state whre there are lots of unreferenced loose objects (say, because many users are doing a bunch of rebasing and pushing their rebased branches). Before this patch, this state would cause a gc.log file to be created, preventing future auto gcs. Then pack files could pile up. Since many git operations are O(n) in the number of pack files, this would lead to poor performance. Now, the pack files will get cleaned up, if necessary, at least once per day. And operators who find a need for more-frequent gcs can adjust gc.logExpiry to meet their needs.
--- Documentation/config.txt | 6 ++++ builtin/gc.c | 76 +++++++++++++++++++++++++++++++++++++++++++----- t/t6500-gc.sh | 12 ++++++++ 3 files changed, 87 insertions(+), 7 deletions(-)
Documentation/config.txt +6 -0
@@ -1402,6 +1402,12 @@ gc.autoDetach:: Make `git gc --auto` return immediately and run in background if the system supports it. Default is true. +gc.logExpiry:: + If the file gc.log exists, then `git gc --auto` won't run + unless that file is more than 'gc.logExpiry' old. Default is + "1.day". See `gc.pruneExpire` for more ways to specify its + value. + gc.packRefs:: Running `git pack-refs` in a repository renders it unclonable by Git versions prior to 1.5.1.2 over dumb
builtin/gc.c +69 -7
121 lines not on this page · raw message
t/t6500-gc.sh +12 -0
@@ -67,5 +67,17 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre test_line_count = 2 new # There is one new pack and its .idx ' +test_expect_success 'background auto gc does not run if gc.log is present and recent but does if it is old' ' + test_commit foo && + test_commit bar && + git repack && + test_config gc.autopacklimit 1 && + test_config gc.autodetach true && + echo fleem >.git/gc.log && + test_must_fail git gc --auto 2>err && + test_i18ngrep "^error:" err && + test-chmtime =-86401 .git/gc.log && + git gc --auto +' test_done
Signature · 1 line
2.11.GIT