gc/repack: release packs when needed
[gitweb.git] / builtin / repack.c
index d5886039cc6656609962fd522a27f61eda6cd0ec..2317608c6b850e3bcf13b153bce583b00af3a28c 100644 (file)
@@ -408,6 +408,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        if (!names.nr && !po_args.quiet)
                printf("Nothing new to pack.\n");
 
+       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
@@ -531,6 +533,12 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                if (!po_args.quiet && isatty(2))
                        opts |= PRUNE_PACKED_VERBOSE;
                prune_packed_objects(opts);
+
+               if (!keep_unreachable &&
+                   (!(pack_everything & LOOSEN_UNREACHABLE) ||
+                    unpack_unreachable) &&
+                   is_repository_shallow(the_repository))
+                       prune_shallow(PRUNE_QUICK);
        }
 
        if (!no_update_server_info)