Skip to content

Commit 5bdece0

Browse files
dschogitster
authored andcommitted
gc/repack: release packs when needed
On Windows, files cannot be removed nor renamed if there are still handles held by a process. To remedy that, we introduced the close_all_packs() function. Earlier, we made sure that the packs are released just before `git gc` is spawned, in case that gc wants to remove no-longer needed packs. But this developer forgot that gc itself also needs to let go of packs, e.g. when consolidating all packs via the --aggressive option. Likewise, `git repack -d` wants to delete obsolete packs and therefore needs to close all pack handles, too. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 98cdfbb commit 5bdece0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

builtin/gc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,10 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
642642

643643
report_garbage = report_pack_garbage;
644644
reprepare_packed_git(the_repository);
645-
if (pack_garbage.nr > 0)
645+
if (pack_garbage.nr > 0) {
646+
close_all_packs(the_repository->objects);
646647
clean_pack_garbage();
648+
}
647649

648650
if (gc_write_commit_graph)
649651
write_commit_graph_reachable(get_object_directory(), 0);

builtin/repack.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
408408
if (!names.nr && !po_args.quiet)
409409
printf("Nothing new to pack.\n");
410410

411+
close_all_packs(the_repository->objects);
412+
411413
/*
412414
* Ok we have prepared all new packfiles.
413415
* First see if there are packs of the same name and if so

0 commit comments

Comments
 (0)