grep: use grep_opt->repo instead of explict repo argument
[gitweb.git] / builtin / repack.c
index 0223f2880ceaec57d10aadb4fcce7a28ce670cc4..2a1c7b21c5d9cb52c328105b470366d1c7ef7c76 100644 (file)
@@ -197,7 +197,7 @@ static int write_oid(const struct object_id *oid, struct packed_git *pack,
 
        if (cmd->in == -1) {
                if (start_command(cmd))
-                       die("Could not start pack-objects to repack promisor objects");
+                       die(_("could not start pack-objects to repack promisor objects"));
        }
 
        xwrite(cmd->in, oid_to_hex(oid), GIT_SHA1_HEXSZ);
@@ -236,7 +236,7 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
                char *promisor_name;
                int fd;
                if (line.len != the_hash_algo->hexsz)
-                       die("repack: Expecting full hex object ID lines only from pack-objects.");
+                       die(_("repack: Expecting full hex object ID lines only from pack-objects."));
                string_list_append(names, line.buf);
 
                /*
@@ -247,13 +247,13 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
                                          line.buf);
                fd = open(promisor_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
                if (fd < 0)
-                       die_errno("unable to create '%s'", promisor_name);
+                       die_errno(_("unable to create '%s'"), promisor_name);
                close(fd);
                free(promisor_name);
        }
        fclose(out);
        if (finish_command(&cmd))
-               die("Could not finish pack-objects to repack promisor objects");
+               die(_("could not finish pack-objects to repack promisor objects"));
 }
 
 #define ALL_INTO_ONE 1
@@ -408,7 +408,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        out = xfdopen(cmd.out, "r");
        while (strbuf_getline_lf(&line, out) != EOF) {
                if (line.len != the_hash_algo->hexsz)
-                       die("repack: Expecting full hex object ID lines only from pack-objects.");
+                       die(_("repack: Expecting full hex object ID lines only from pack-objects."));
                string_list_append(&names, line.buf);
        }
        fclose(out);
@@ -417,7 +417,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                return ret;
 
        if (!names.nr && !po_args.quiet)
-               printf("Nothing new to pack.\n");
+               printf_ln(_("Nothing new to pack."));
 
        /*
         * Ok we have prepared all new packfiles.
@@ -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;
                        }
 
@@ -477,13 +476,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                if (rollback_failure.nr) {
                        int i;
                        fprintf(stderr,
-                               "WARNING: Some packs in use have been renamed by\n"
-                               "WARNING: prefixing old- to their name, in order to\n"
-                               "WARNING: replace them with the new version of the\n"
-                               "WARNING: file.  But the operation failed, and the\n"
-                               "WARNING: attempt to rename them back to their\n"
-                               "WARNING: original names also failed.\n"
-                               "WARNING: Please rename them in %s manually:\n", packdir);
+                               _("WARNING: Some packs in use have been renamed by\n"
+                                 "WARNING: prefixing old- to their name, in order to\n"
+                                 "WARNING: replace them with the new version of the\n"
+                                 "WARNING: file.  But the operation failed, and the\n"
+                                 "WARNING: attempt to rename them back to their\n"
+                                 "WARNING: original names also failed.\n"
+                                 "WARNING: Please rename them in %s manually:\n"), packdir);
                        for (i = 0; i < rollback_failure.nr; i++)
                                fprintf(stderr, "WARNING:   old-%s -> %s\n",
                                        rollback_failure.items[i].string,
@@ -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);