fetch: release pack files before garbage-collecting
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 13 Jan 2016 17:20:11 +0000 (18:20 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 Jan 2016 19:36:27 +0000 (11:36 -0800)
Before auto-gc'ing, we need to make sure that the pack files are
released in case they need to be repacked and garbage-collected.

This fixes https://github.com/git-for-windows/git/issues/500

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
t/t5510-fetch.sh
index c85f3471d4b53ce7db7662b5531ddebe5513b7b0..5b58001a982d0c0361c8693d05c609fd0b5fcd9c 100644 (file)
@@ -1221,6 +1221,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        list.strdup_strings = 1;
        string_list_clear(&list, 0);
 
+       close_all_packs();
+
        argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
        if (verbosity < 0)
                argv_array_push(&argv_gc_auto, "--quiet");
index 0ba9db08847255d28e3e185d18b68703fb0755dc..e3ee4bd700c3e72479ce1c7a4d8b1333a35a8473 100755 (executable)
@@ -708,4 +708,17 @@ test_expect_success 'fetching a one-level ref works' '
        )
 '
 
+test_expect_success 'fetching with auto-gc does not lock up' '
+       write_script askyesno <<-\EOF &&
+       echo "$*" &&
+       false
+       EOF
+       git clone "file://$D" auto-gc &&
+       test_commit test2 &&
+       cd auto-gc &&
+       git config gc.autoPackLimit 1 &&
+       GIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 &&
+       ! grep "Should I try again" fetch.out
+'
+
 test_done