submodule-config: add repository argument to submodule_from_{name, path}
[gitweb.git] / builtin / index-pack.c
index 4f305a704c376ac18fe3936314315cb21adb2364..1d6bc87b7694a3d63fdfb0e7e96ec1db7bb80056 100644 (file)
@@ -13,6 +13,7 @@
 #include "streaming.h"
 #include "thread-utils.h"
 #include "packfile.h"
+#include "object-store.h"
 
 static const char index_pack_usage[] =
 "git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
@@ -1429,14 +1430,16 @@ static void write_special_file(const char *suffix, const char *msg,
                if (close(fd) != 0)
                        die_errno(_("cannot close written %s file '%s'"),
                                  suffix, filename);
-               *report = suffix;
+               if (report)
+                       *report = suffix;
        }
        strbuf_release(&name_buf);
 }
 
 static void final(const char *final_pack_name, const char *curr_pack_name,
                  const char *final_index_name, const char *curr_index_name,
-                 const char *keep_msg, unsigned char *sha1)
+                 const char *keep_msg, const char *promisor_msg,
+                 unsigned char *sha1)
 {
        const char *report = "pack";
        struct strbuf pack_name = STRBUF_INIT;
@@ -1455,6 +1458,9 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
        if (keep_msg)
                write_special_file("keep", keep_msg, final_pack_name, sha1,
                                   &report);
+       if (promisor_msg)
+               write_special_file("promisor", promisor_msg, final_pack_name,
+                                  sha1, NULL);
 
        if (final_pack_name != curr_pack_name) {
                if (!final_pack_name)
@@ -1644,6 +1650,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
        const char *curr_index;
        const char *index_name = NULL, *pack_name = NULL;
        const char *keep_msg = NULL;
+       const char *promisor_msg = NULL;
        struct strbuf index_name_buf = STRBUF_INIT;
        struct pack_idx_entry **idx_objects;
        struct pack_idx_option opts;
@@ -1651,6 +1658,12 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
        unsigned foreign_nr = 1;        /* zero is a "good" value, assume bad */
        int report_end_of_input = 0;
 
+       /*
+        * index-pack never needs to fetch missing objects, since it only
+        * accesses the repo to do hash collision checks
+        */
+       fetch_if_missing = 0;
+
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage(index_pack_usage);
 
@@ -1670,10 +1683,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
                                from_stdin = 1;
                        } else if (!strcmp(arg, "--fix-thin")) {
                                fix_thin_pack = 1;
-                       } else if (!strcmp(arg, "--strict")) {
-                               strict = 1;
-                               do_fsck_object = 1;
-                       } else if (skip_prefix(arg, "--strict=", &arg)) {
+                       } else if (skip_to_optional_arg(arg, "--strict", &arg)) {
                                strict = 1;
                                do_fsck_object = 1;
                                fsck_set_msg_types(&fsck_options, arg);
@@ -1689,10 +1699,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
                                verify = 1;
                                show_stat = 1;
                                stat_only = 1;
-                       } else if (!strcmp(arg, "--keep")) {
-                               keep_msg = "";
-                       } else if (starts_with(arg, "--keep=")) {
-                               keep_msg = arg + 7;
+                       } else if (skip_to_optional_arg(arg, "--keep", &keep_msg)) {
+                               ; /* nothing to do */
+                       } else if (skip_to_optional_arg(arg, "--promisor", &promisor_msg)) {
+                               ; /* already parsed */
                        } else if (starts_with(arg, "--threads=")) {
                                char *end;
                                nr_threads = strtoul(arg+10, &end, 0);
@@ -1803,7 +1813,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
        if (!verify)
                final(pack_name, curr_pack,
                      index_name, curr_index,
-                     keep_msg,
+                     keep_msg, promisor_msg,
                      pack_sha1);
        else
                close(input_fd);