Merge branch 'sb/cocci-pending'
[gitweb.git] / builtin / repack.c
index 0223f2880ceaec57d10aadb4fcce7a28ce670cc4..45583683eef4d59d1c8b957a8d9a8c0834db0e48 100644 (file)
@@ -431,8 +431,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                        char *fname, *fname_old;
 
                        if (!midx_cleared) {
-                               /* if we move a packfile, it will invalidated the midx */
-                               clear_midx_file(get_object_directory());
+                               clear_midx_file(the_repository);
                                midx_cleared = 1;
                        }
 
@@ -550,11 +549,21 @@ 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)
                update_server_info(0);
        remove_temporary_files();
+
+       if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0))
+               write_midx_file(get_object_directory());
+
        string_list_clear(&names, 0);
        string_list_clear(&rollback, 0);
        string_list_clear(&existing_packs, 0);