Merge branch 'js/gc-repack-close-before-remove'
authorJunio C Hamano <gitster@pobox.com>
Fri, 18 Jan 2019 21:49:57 +0000 (13:49 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Jan 2019 21:49:57 +0000 (13:49 -0800)
"git gc" and "git repack" did not close the open packfiles that
they found unneeded before removing them, which didn't work on a
platform incapable of removing an open file. This has been
corrected.

* js/gc-repack-close-before-remove:
gc/repack: release packs when needed

1  2 
builtin/gc.c
builtin/repack.c
diff --cc builtin/gc.c
index 7696017cd4152eb191972d2d662c592030ac811e,8a99ed2af2ba341af037224cd529dbfd031ac222..020f725acc40f413c49f812ea0e6aac0153d097c
@@@ -659,12 -642,13 +659,14 @@@ int cmd_gc(int argc, const char **argv
  
        report_garbage = report_pack_garbage;
        reprepare_packed_git(the_repository);
-       if (pack_garbage.nr > 0)
+       if (pack_garbage.nr > 0) {
+               close_all_packs(the_repository->objects);
                clean_pack_garbage();
+       }
  
        if (gc_write_commit_graph)
 -              write_commit_graph_reachable(get_object_directory(), 0);
 +              write_commit_graph_reachable(get_object_directory(), 0,
 +                                           !quiet && !daemonized);
  
        if (auto_gc && too_many_loose_objects())
                warning(_("There are too many unreachable loose objects; "
index 2a1c7b21c5d9cb52c328105b470366d1c7ef7c76,2317608c6b850e3bcf13b153bce583b00af3a28c..67f8978043a43988d653092f83f21bd5baad9751
@@@ -417,8 -406,10 +417,10 @@@ int cmd_repack(int argc, const char **a
                return ret;
  
        if (!names.nr && !po_args.quiet)
 -              printf("Nothing new to pack.\n");
 +              printf_ln(_("Nothing new to pack."));
  
+       close_all_packs(the_repository->objects);
        /*
         * Ok we have prepared all new packfiles.
         * First see if there are packs of the same name and if so