gc --auto: release pack files before auto packing

Teach gc --auto to release pack files before auto packing the repository to prevent failures when removing them. Also teach the test 'fetching with auto-gc does not lock up' to complain when it is no longer triggering an auto packing of the repository. Fixes https://github.com/git-for-windows/git/issues/500 Signed-off-by: Kim Gybels <kgybels@infogroep.be> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kim Gybels committed Jul 9, 2018 at 22:37 UTC 12e73a3ce46135279cec8fc9ef0068948936e6f8
2 files changed +3
builtin/gc.c
+1
@@ -612,6 +612,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
612 return -1;
613
614 if (!repository_format_precious_objects) {
615 + close_all_packs(the_repository->objects);
616 if (run_command_v_opt(repack.argv, RUN_GIT_CMD))
617 return error(FAILED_RUN, repack.argv[0]);
618
t/t5510-fetch.sh
+2
@@ -828,9 +828,11 @@ test_expect_success 'fetching with auto-gc does not lock up' '
828 test_commit test2 &&
829 (
830 cd auto-gc &&
831 + git config fetch.unpackLimit 1 &&
832 git config gc.autoPackLimit 1 &&
833 git config gc.autoDetach false &&
834 GIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 &&
835 + test_i18ngrep "Auto packing the repository" fetch.out &&
836 ! grep "Should I try again" fetch.out
837 )
838 '