Skip to content

Commit 0898c96

Browse files
dschogitster
authored andcommitted
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 #500 Signed-off-by: Johannes Schindelin <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7548842 commit 0898c96

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

builtin/fetch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
12211221
list.strdup_strings = 1;
12221222
string_list_clear(&list, 0);
12231223

1224+
close_all_packs();
1225+
12241226
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
12251227
if (verbosity < 0)
12261228
argv_array_push(&argv_gc_auto, "--quiet");

t/t5510-fetch.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,4 +708,17 @@ test_expect_success 'fetching a one-level ref works' '
708708
)
709709
'
710710

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+
711724
test_done

0 commit comments

Comments
 (0)