gc --auto: release pack files before auto packing
authorKim Gybels <kgybels@infogroep.be>
Mon, 9 Jul 2018 20:37:27 +0000 (22:37 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Jul 2018 21:16:10 +0000 (14:16 -0700)
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>
builtin/gc.c
t/t5510-fetch.sh
index ccfb1ceaeb3eb9c6a8cbe9297bceac94fa54bcac..63b62ab57c297d1873a529b9c55768eebca999b1 100644 (file)
@@ -612,6 +612,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
                return -1;
 
        if (!repository_format_precious_objects) {
+               close_all_packs(the_repository->objects);
                if (run_command_v_opt(repack.argv, RUN_GIT_CMD))
                        return error(FAILED_RUN, repack.argv[0]);
 
index e402aee6a22e64306c9f093ad1b529b3923fd65e..6f1450eb698fa5563528f2437375681577647690 100755 (executable)
@@ -828,9 +828,11 @@ test_expect_success 'fetching with auto-gc does not lock up' '
        test_commit test2 &&
        (
                cd auto-gc &&
+               git config fetch.unpackLimit 1 &&
                git config gc.autoPackLimit 1 &&
                git config gc.autoDetach false &&
                GIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 &&
+               test_i18ngrep "Auto packing the repository" fetch.out &&
                ! grep "Should I try again" fetch.out
        )
 '