Skip to content

Commit 3c80940

Browse files
committed
Merge branch 'js/close-packs-before-gc'
Many codepaths that run "gc --auto" before exiting kept packfiles mapped and left the file descriptors to them open, which was not friendly to systems that cannot remove files that are open. They now close the packs before doing so. * js/close-packs-before-gc: receive-pack: release pack files before garbage-collecting merge: release pack files before garbage-collecting am: release pack files before garbage-collecting fetch: release pack files before garbage-collecting
2 parents eefc461 + d562102 commit 3c80940

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

builtin/am.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,7 @@ static void am_run(struct am_state *state, int resume)
19391939
*/
19401940
if (!state->rebasing) {
19411941
am_destroy(state);
1942+
close_all_packs();
19421943
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
19431944
}
19441945
}

builtin/fetch.c

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

1228+
close_all_packs();
1229+
12281230
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
12291231
if (verbosity < 0)
12301232
argv_array_push(&argv_gc_auto, "--quiet");

builtin/merge.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ static void finish(struct commit *head_commit,
404404
* We ignore errors in 'gc --auto', since the
405405
* user should see them.
406406
*/
407+
close_all_packs();
407408
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
408409
}
409410
}

builtin/receive-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
17961796
"gc", "--auto", "--quiet", NULL,
17971797
};
17981798
int opt = RUN_GIT_CMD | RUN_COMMAND_STDOUT_TO_STDERR;
1799+
close_all_packs();
17991800
run_command_v_opt(argv_gc_auto, opt);
18001801
}
18011802
if (auto_update_server_info)

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)