fetch: release pack files before garbage-collecting

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>

Johannes Schindelin committed Jan 13, 2016 at 18:20 UTC 0898c96281044a1130f1a777660aaf17e782c4f6
2 files changed +15
builtin/fetch.c
+2
@@ -1221,6 +1221,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1221 list.strdup_strings = 1;
1222 string_list_clear(&list, 0);
1223
1224 + close_all_packs();
1225 +
1226 argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
1227 if (verbosity < 0)
1228 argv_array_push(&argv_gc_auto, "--quiet");
t/t5510-fetch.sh
+13
@@ -708,4 +708,17 @@ test_expect_success 'fetching a one-level ref works' '
708 )
709 '
710
711 +test_expect_success 'fetching with auto-gc does not lock up' '
712 + write_script askyesno <<-\EOF &&
713 + echo "$*" &&
714 + false
715 + EOF
716 + git clone "file://$D" auto-gc &&
717 + test_commit test2 &&
718 + cd auto-gc &&
719 + git config gc.autoPackLimit 1 &&
720 + GIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 &&
721 + ! grep "Should I try again" fetch.out
722 +'
723 +
724 test_done