fetch-pack: add --no-filter
[gitweb.git] / builtin / index-pack.c
index 4f305a704c376ac18fe3936314315cb21adb2364..a0a35e69c0a044fa40a2481c22ef56a766b23e41 100644 (file)
@@ -1429,14 +1429,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 +1457,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 +1649,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 +1657,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);
 
@@ -1693,6 +1705,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
                                keep_msg = "";
                        } else if (starts_with(arg, "--keep=")) {
                                keep_msg = arg + 7;
+                       } else if (!strcmp(arg, "--promisor")) {
+                               promisor_msg = "";
+                       } else if (starts_with(arg, "--promisor=")) {
+                               promisor_msg = arg + strlen("--promisor=");
                        } else if (starts_with(arg, "--threads=")) {
                                char *end;
                                nr_threads = strtoul(arg+10, &end, 0);
@@ -1803,7 +1819,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);