Skip to content

Commit 85bc5ad

Browse files
committed
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]>
1 parent 85315b6 commit 85bc5ad

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
@@ -434,8 +434,10 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
434434

435435
report_garbage = report_pack_garbage;
436436
reprepare_packed_git();
437-
if (pack_garbage.nr > 0)
437+
if (pack_garbage.nr > 0) {
438+
close_all_packs();
438439
clean_pack_garbage();
440+
}
439441

440442
if (auto_gc && too_many_loose_objects())
441443
warning(_("There are too many unreachable loose objects; "

builtin/repack.c

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

282+
close_all_packs();
283+
282284
/*
283285
* Ok we have prepared all new packfiles.
284286
* First see if there are packs of the same name and if so

0 commit comments

Comments
 (0)