]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/pack-objects.c
Merge branch 'ot/mru-on-list'
[thirdparty/git.git] / builtin / pack-objects.c
index ba812349e0aab35c2a009fe3c7da407ec8b7f48c..0c3d03de487e1645a11d379dc5966cd9b2be81dd 100644 (file)
@@ -15,6 +15,8 @@
 #include "diff.h"
 #include "revision.h"
 #include "list-objects.h"
+#include "list-objects-filter.h"
+#include "list-objects-filter-options.h"
 #include "pack-objects.h"
 #include "progress.h"
 #include "refs.h"
@@ -73,12 +75,24 @@ static int use_bitmap_index = -1;
 static int write_bitmap_index;
 static uint16_t write_bitmap_options;
 
+static int exclude_promisor_objects;
+
 static unsigned long delta_cache_size = 0;
 static unsigned long max_delta_cache_size = 256 * 1024 * 1024;
 static unsigned long cache_max_small_delta_size = 1000;
 
 static unsigned long window_memory_limit = 0;
 
+static struct list_objects_filter_options filter_options;
+
+enum missing_action {
+       MA_ERROR = 0,      /* fail if any missing objects are encountered */
+       MA_ALLOW_ANY,      /* silently allow ALL missing objects */
+       MA_ALLOW_PROMISOR, /* silently allow all missing PROMISOR objects */
+};
+static enum missing_action arg_missing_action;
+static show_object_fn fn_show_object;
+
 /*
  * stats
  */
@@ -151,7 +165,7 @@ static unsigned long do_compress(void **pptr, unsigned long size)
 }
 
 static unsigned long write_large_blob_data(struct git_istream *st, struct sha1file *f,
-                                          const unsigned char *sha1)
+                                          const struct object_id *oid)
 {
        git_zstream stream;
        unsigned char ibuf[1024 * 16];
@@ -165,7 +179,7 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct sha1fi
                int zret = Z_OK;
                readlen = read_istream(st, ibuf, sizeof(ibuf));
                if (readlen == -1)
-                       die(_("unable to read %s"), sha1_to_hex(sha1));
+                       die(_("unable to read %s"), oid_to_hex(oid));
 
                stream.next_in = ibuf;
                stream.avail_in = readlen;
@@ -339,7 +353,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
                sha1write(f, header, hdrlen);
        }
        if (st) {
-               datalen = write_large_blob_data(st, f, entry->idx.oid.hash);
+               datalen = write_large_blob_data(st, f, &entry->idx.oid);
                close_istream(st);
        } else {
                sha1write(f, buf, datalen);
@@ -557,13 +571,13 @@ static enum write_one_status write_one(struct sha1file *f,
 static int mark_tagged(const char *path, const struct object_id *oid, int flag,
                       void *cb_data)
 {
-       unsigned char peeled[20];
+       struct object_id peeled;
        struct object_entry *entry = packlist_find(&to_pack, oid->hash, NULL);
 
        if (entry)
                entry->tagged = 1;
-       if (!peel_ref(path, peeled)) {
-               entry = packlist_find(&to_pack, peeled, NULL);
+       if (!peel_ref(path, &peeled)) {
+               entry = packlist_find(&to_pack, peeled.hash, NULL);
                if (entry)
                        entry->tagged = 1;
        }
@@ -792,7 +806,7 @@ static void write_pack_file(void)
        write_order = compute_write_order();
 
        do {
-               unsigned char sha1[20];
+               struct object_id oid;
                char *pack_tmp_name = NULL;
 
                if (pack_to_stdout)
@@ -823,13 +837,13 @@ static void write_pack_file(void)
                 * If so, rewrite it like in fast-import
                 */
                if (pack_to_stdout) {
-                       sha1close(f, sha1, CSUM_CLOSE);
+                       sha1close(f, oid.hash, CSUM_CLOSE);
                } else if (nr_written == nr_remaining) {
-                       sha1close(f, sha1, CSUM_FSYNC);
+                       sha1close(f, oid.hash, CSUM_FSYNC);
                } else {
-                       int fd = sha1close(f, sha1, 0);
-                       fixup_pack_header_footer(fd, sha1, pack_tmp_name,
-                                                nr_written, sha1, offset);
+                       int fd = sha1close(f, oid.hash, 0);
+                       fixup_pack_header_footer(fd, oid.hash, pack_tmp_name,
+                                                nr_written, oid.hash, offset);
                        close(fd);
                        if (write_bitmap_index) {
                                warning(_(no_split_warning));
@@ -863,16 +877,16 @@ static void write_pack_file(void)
                        strbuf_addf(&tmpname, "%s-", base_name);
 
                        if (write_bitmap_index) {
-                               bitmap_writer_set_checksum(sha1);
+                               bitmap_writer_set_checksum(oid.hash);
                                bitmap_writer_build_type_index(written_list, nr_written);
                        }
 
                        finish_tmp_packfile(&tmpname, pack_tmp_name,
                                            written_list, nr_written,
-                                           &pack_idx_opts, sha1);
+                                           &pack_idx_opts, oid.hash);
 
                        if (write_bitmap_index) {
-                               strbuf_addf(&tmpname, "%s.bitmap", sha1_to_hex(sha1));
+                               strbuf_addf(&tmpname, "%s.bitmap", oid_to_hex(&oid));
 
                                stop_progress(&progress_state);
 
@@ -887,7 +901,7 @@ static void write_pack_file(void)
 
                        strbuf_release(&tmpname);
                        free(pack_tmp_name);
-                       puts(sha1_to_hex(sha1));
+                       puts(oid_to_hex(&oid));
                }
 
                /* mark written objects as written to previous pack */
@@ -928,13 +942,13 @@ static int no_try_delta(const char *path)
  * found the item, since that saves us from having to look it up again a
  * few lines later when we want to add the new entry.
  */
-static int have_duplicate_entry(const unsigned char *sha1,
+static int have_duplicate_entry(const struct object_id *oid,
                                int exclude,
                                uint32_t *index_pos)
 {
        struct object_entry *entry;
 
-       entry = packlist_find(&to_pack, sha1, index_pos);
+       entry = packlist_find(&to_pack, oid->hash, index_pos);
        if (!entry)
                return 0;
 
@@ -990,7 +1004,7 @@ static int want_found_object(int exclude, struct packed_git *p)
  * function finds if there is any pack that has the object and returns the pack
  * and its offset in these variables.
  */
-static int want_object_in_pack(const unsigned char *sha1,
+static int want_object_in_pack(const struct object_id *oid,
                               int exclude,
                               struct packed_git **found_pack,
                               off_t *found_offset)
@@ -998,7 +1012,7 @@ static int want_object_in_pack(const unsigned char *sha1,
        int want;
        struct list_head *pos;
 
-       if (!exclude && local && has_loose_object_nonlocal(sha1))
+       if (!exclude && local && has_loose_object_nonlocal(oid->hash))
                return 0;
 
        /*
@@ -1020,7 +1034,7 @@ static int want_object_in_pack(const unsigned char *sha1,
                if (p == *found_pack)
                        offset = *found_offset;
                else
-                       offset = find_pack_entry_one(sha1, p);
+                       offset = find_pack_entry_one(oid->hash, p);
 
                if (offset) {
                        if (!*found_pack) {
@@ -1040,7 +1054,7 @@ static int want_object_in_pack(const unsigned char *sha1,
        return 1;
 }
 
-static void create_object_entry(const unsigned char *sha1,
+static void create_object_entry(const struct object_id *oid,
                                enum object_type type,
                                uint32_t hash,
                                int exclude,
@@ -1051,7 +1065,7 @@ static void create_object_entry(const unsigned char *sha1,
 {
        struct object_entry *entry;
 
-       entry = packlist_alloc(&to_pack, sha1, index_pos);
+       entry = packlist_alloc(&to_pack, oid->hash, index_pos);
        entry->hash = hash;
        if (type)
                entry->type = type;
@@ -1071,17 +1085,17 @@ static const char no_closure_warning[] = N_(
 "disabling bitmap writing, as some objects are not being packed"
 );
 
-static int add_object_entry(const unsigned char *sha1, enum object_type type,
+static int add_object_entry(const struct object_id *oid, enum object_type type,
                            const char *name, int exclude)
 {
        struct packed_git *found_pack = NULL;
        off_t found_offset = 0;
        uint32_t index_pos;
 
-       if (have_duplicate_entry(sha1, exclude, &index_pos))
+       if (have_duplicate_entry(oid, exclude, &index_pos))
                return 0;
 
-       if (!want_object_in_pack(sha1, exclude, &found_pack, &found_offset)) {
+       if (!want_object_in_pack(oid, exclude, &found_pack, &found_offset)) {
                /* The pack is missing an object, so it will not have closure */
                if (write_bitmap_index) {
                        warning(_(no_closure_warning));
@@ -1090,7 +1104,7 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
                return 0;
        }
 
-       create_object_entry(sha1, type, pack_name_hash(name),
+       create_object_entry(oid, type, pack_name_hash(name),
                            exclude, name && no_try_delta(name),
                            index_pos, found_pack, found_offset);
 
@@ -1098,27 +1112,27 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
        return 1;
 }
 
-static int add_object_entry_from_bitmap(const unsigned char *sha1,
+static int add_object_entry_from_bitmap(const struct object_id *oid,
                                        enum object_type type,
                                        int flags, uint32_t name_hash,
                                        struct packed_git *pack, off_t offset)
 {
        uint32_t index_pos;
 
-       if (have_duplicate_entry(sha1, 0, &index_pos))
+       if (have_duplicate_entry(oid, 0, &index_pos))
                return 0;
 
-       if (!want_object_in_pack(sha1, 0, &pack, &offset))
+       if (!want_object_in_pack(oid, 0, &pack, &offset))
                return 0;
 
-       create_object_entry(sha1, type, name_hash, 0, 0, index_pos, pack, offset);
+       create_object_entry(oid, type, name_hash, 0, 0, index_pos, pack, offset);
 
        display_progress(progress_state, nr_result);
        return 1;
 }
 
 struct pbase_tree_cache {
-       unsigned char sha1[20];
+       struct object_id oid;
        int ref;
        int temporary;
        void *tree_data;
@@ -1126,9 +1140,9 @@ struct pbase_tree_cache {
 };
 
 static struct pbase_tree_cache *(pbase_tree_cache[256]);
-static int pbase_tree_cache_ix(const unsigned char *sha1)
+static int pbase_tree_cache_ix(const struct object_id *oid)
 {
-       return sha1[0] % ARRAY_SIZE(pbase_tree_cache);
+       return oid->hash[0] % ARRAY_SIZE(pbase_tree_cache);
 }
 static int pbase_tree_cache_ix_incr(int ix)
 {
@@ -1145,14 +1159,14 @@ static struct pbase_tree {
        struct pbase_tree_cache pcache;
 } *pbase_tree;
 
-static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)
+static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
 {
        struct pbase_tree_cache *ent, *nent;
        void *data;
        unsigned long size;
        enum object_type type;
        int neigh;
-       int my_ix = pbase_tree_cache_ix(sha1);
+       int my_ix = pbase_tree_cache_ix(oid);
        int available_ix = -1;
 
        /* pbase-tree-cache acts as a limited hashtable.
@@ -1161,7 +1175,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)
         */
        for (neigh = 0; neigh < 8; neigh++) {
                ent = pbase_tree_cache[my_ix];
-               if (ent && !hashcmp(ent->sha1, sha1)) {
+               if (ent && !oidcmp(&ent->oid, oid)) {
                        ent->ref++;
                        return ent;
                }
@@ -1177,7 +1191,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)
        /* Did not find one.  Either we got a bogus request or
         * we need to read and perhaps cache.
         */
-       data = read_sha1_file(sha1, &type, &size);
+       data = read_sha1_file(oid->hash, &type, &size);
        if (!data)
                return NULL;
        if (type != OBJ_TREE) {
@@ -1203,7 +1217,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)
                free(ent->tree_data);
                nent = ent;
        }
-       hashcpy(nent->sha1, sha1);
+       oidcpy(&nent->oid, oid);
        nent->tree_data = data;
        nent->tree_size = size;
        nent->ref = 1;
@@ -1248,7 +1262,7 @@ static void add_pbase_object(struct tree_desc *tree,
                if (cmp < 0)
                        return;
                if (name[cmplen] != '/') {
-                       add_object_entry(entry.oid->hash,
+                       add_object_entry(entry.oid,
                                         object_type(entry.mode),
                                         fullname, 1);
                        return;
@@ -1259,7 +1273,7 @@ static void add_pbase_object(struct tree_desc *tree,
                        const char *down = name+cmplen+1;
                        int downlen = name_cmp_len(down);
 
-                       tree = pbase_tree_get(entry.oid->hash);
+                       tree = pbase_tree_get(entry.oid);
                        if (!tree)
                                return;
                        init_tree_desc(&sub, tree->tree_data, tree->tree_size);
@@ -1278,7 +1292,7 @@ static int done_pbase_path_pos(unsigned hash)
        int lo = 0;
        int hi = done_pbase_paths_num;
        while (lo < hi) {
-               int mi = (hi + lo) / 2;
+               int mi = lo + (hi - lo) / 2;
                if (done_pbase_paths[mi] == hash)
                        return mi;
                if (done_pbase_paths[mi] < hash)
@@ -1318,7 +1332,7 @@ static void add_preferred_base_object(const char *name)
        cmplen = name_cmp_len(name);
        for (it = pbase_tree; it; it = it->next) {
                if (cmplen == 0) {
-                       add_object_entry(it->pcache.sha1, OBJ_TREE, NULL, 1);
+                       add_object_entry(&it->pcache.oid, OBJ_TREE, NULL, 1);
                }
                else {
                        struct tree_desc tree;
@@ -1328,22 +1342,22 @@ static void add_preferred_base_object(const char *name)
        }
 }
 
-static void add_preferred_base(unsigned char *sha1)
+static void add_preferred_base(struct object_id *oid)
 {
        struct pbase_tree *it;
        void *data;
        unsigned long size;
-       unsigned char tree_sha1[20];
+       struct object_id tree_oid;
 
        if (window <= num_preferred_base++)
                return;
 
-       data = read_object_with_reference(sha1, tree_type, &size, tree_sha1);
+       data = read_object_with_reference(oid->hash, tree_type, &size, tree_oid.hash);
        if (!data)
                return;
 
        for (it = pbase_tree; it; it = it->next) {
-               if (!hashcmp(it->pcache.sha1, tree_sha1)) {
+               if (!oidcmp(&it->pcache.oid, &tree_oid)) {
                        free(data);
                        return;
                }
@@ -1353,7 +1367,7 @@ static void add_preferred_base(unsigned char *sha1)
        it->next = pbase_tree;
        pbase_tree = it;
 
-       hashcpy(it->pcache.sha1, tree_sha1);
+       oidcpy(&it->pcache.oid, &tree_oid);
        it->pcache.tree_data = data;
        it->pcache.tree_size = size;
 }
@@ -2358,7 +2372,7 @@ static void add_tag_chain(const struct object_id *oid)
                        die("unable to pack objects reachable from tag %s",
                            oid_to_hex(oid));
 
-               add_object_entry(tag->object.oid.hash, OBJ_TAG, NULL, 0);
+               add_object_entry(&tag->object.oid, OBJ_TAG, NULL, 0);
 
                if (tag->tagged->type != OBJ_TAG)
                        return;
@@ -2372,7 +2386,7 @@ static int add_ref_tag(const char *path, const struct object_id *oid, int flag,
        struct object_id peeled;
 
        if (starts_with(path, "refs/tags/") && /* is a tag? */
-           !peel_ref(path, peeled.hash)    && /* peelable? */
+           !peel_ref(path, &peeled)    && /* peelable? */
            packlist_find(&to_pack, peeled.hash, NULL))      /* object packed? */
                add_tag_chain(oid);
        return 0;
@@ -2506,8 +2520,9 @@ static int git_pack_config(const char *k, const char *v, void *cb)
 
 static void read_object_list_from_stdin(void)
 {
-       char line[40 + 1 + PATH_MAX + 2];
-       unsigned char sha1[20];
+       char line[GIT_MAX_HEXSZ + 1 + PATH_MAX + 2];
+       struct object_id oid;
+       const char *p;
 
        for (;;) {
                if (!fgets(line, sizeof(line), stdin)) {
@@ -2521,17 +2536,17 @@ static void read_object_list_from_stdin(void)
                        continue;
                }
                if (line[0] == '-') {
-                       if (get_sha1_hex(line+1, sha1))
-                               die("expected edge sha1, got garbage:\n %s",
+                       if (get_oid_hex(line+1, &oid))
+                               die("expected edge object ID, got garbage:\n %s",
                                    line);
-                       add_preferred_base(sha1);
+                       add_preferred_base(&oid);
                        continue;
                }
-               if (get_sha1_hex(line, sha1))
-                       die("expected sha1, got garbage:\n %s", line);
+               if (parse_oid_hex(line, &oid, &p))
+                       die("expected object ID, got garbage:\n %s", line);
 
-               add_preferred_base_object(line+41);
-               add_object_entry(sha1, 0, line+41, 0);
+               add_preferred_base_object(p + 1);
+               add_object_entry(&oid, 0, p + 1, 0);
        }
 }
 
@@ -2539,7 +2554,7 @@ static void read_object_list_from_stdin(void)
 
 static void show_commit(struct commit *commit, void *data)
 {
-       add_object_entry(commit->object.oid.hash, OBJ_COMMIT, NULL, 0);
+       add_object_entry(&commit->object.oid, OBJ_COMMIT, NULL, 0);
        commit->object.flags |= OBJECT_ADDED;
 
        if (write_bitmap_index)
@@ -2549,13 +2564,71 @@ static void show_commit(struct commit *commit, void *data)
 static void show_object(struct object *obj, const char *name, void *data)
 {
        add_preferred_base_object(name);
-       add_object_entry(obj->oid.hash, obj->type, name, 0);
+       add_object_entry(&obj->oid, obj->type, name, 0);
        obj->flags |= OBJECT_ADDED;
 }
 
+static void show_object__ma_allow_any(struct object *obj, const char *name, void *data)
+{
+       assert(arg_missing_action == MA_ALLOW_ANY);
+
+       /*
+        * Quietly ignore ALL missing objects.  This avoids problems with
+        * staging them now and getting an odd error later.
+        */
+       if (!has_object_file(&obj->oid))
+               return;
+
+       show_object(obj, name, data);
+}
+
+static void show_object__ma_allow_promisor(struct object *obj, const char *name, void *data)
+{
+       assert(arg_missing_action == MA_ALLOW_PROMISOR);
+
+       /*
+        * Quietly ignore EXPECTED missing objects.  This avoids problems with
+        * staging them now and getting an odd error later.
+        */
+       if (!has_object_file(&obj->oid) && is_promisor_object(&obj->oid))
+               return;
+
+       show_object(obj, name, data);
+}
+
+static int option_parse_missing_action(const struct option *opt,
+                                      const char *arg, int unset)
+{
+       assert(arg);
+       assert(!unset);
+
+       if (!strcmp(arg, "error")) {
+               arg_missing_action = MA_ERROR;
+               fn_show_object = show_object;
+               return 0;
+       }
+
+       if (!strcmp(arg, "allow-any")) {
+               arg_missing_action = MA_ALLOW_ANY;
+               fetch_if_missing = 0;
+               fn_show_object = show_object__ma_allow_any;
+               return 0;
+       }
+
+       if (!strcmp(arg, "allow-promisor")) {
+               arg_missing_action = MA_ALLOW_PROMISOR;
+               fetch_if_missing = 0;
+               fn_show_object = show_object__ma_allow_promisor;
+               return 0;
+       }
+
+       die(_("invalid value for --missing"));
+       return 0;
+}
+
 static void show_edge(struct commit *commit)
 {
-       add_preferred_base(commit->object.oid.hash);
+       add_preferred_base(&commit->object.oid);
 }
 
 struct in_pack_object {
@@ -2564,8 +2637,8 @@ struct in_pack_object {
 };
 
 struct in_pack {
-       int alloc;
-       int nr;
+       unsigned int alloc;
+       unsigned int nr;
        struct in_pack_object *array;
 };
 
@@ -2602,7 +2675,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
        memset(&in_pack, 0, sizeof(in_pack));
 
        for (p = packed_git; p; p = p->next) {
-               const unsigned char *sha1;
+               struct object_id oid;
                struct object *o;
 
                if (!p->pack_local || p->pack_keep)
@@ -2615,8 +2688,8 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
                           in_pack.alloc);
 
                for (i = 0; i < p->num_objects; i++) {
-                       sha1 = nth_packed_object_sha1(p, i);
-                       o = lookup_unknown_object(sha1);
+                       nth_packed_object_oid(&oid, p, i);
+                       o = lookup_unknown_object(oid.hash);
                        if (!(o->flags & OBJECT_ADDED))
                                mark_in_pack_object(o, p, &in_pack);
                        o->flags |= OBJECT_ADDED;
@@ -2627,7 +2700,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
                QSORT(in_pack.array, in_pack.nr, ofscmp);
                for (i = 0; i < in_pack.nr; i++) {
                        struct object *o = in_pack.array[i].object;
-                       add_object_entry(o->oid.hash, o->type, "", 0);
+                       add_object_entry(&o->oid, o->type, "", 0);
                }
        }
        free(in_pack.array);
@@ -2643,7 +2716,7 @@ static int add_loose_object(const struct object_id *oid, const char *path,
                return 0;
        }
 
-       add_object_entry(oid->hash, type, "", 0);
+       add_object_entry(oid, type, "", 0);
        return 0;
 }
 
@@ -2659,7 +2732,7 @@ static void add_unreachable_loose_objects(void)
                                      NULL, NULL, NULL);
 }
 
-static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)
+static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
 {
        static struct packed_git *last_found = (void *)1;
        struct packed_git *p;
@@ -2668,7 +2741,7 @@ static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)
 
        while (p) {
                if ((!p->pack_local || p->pack_keep) &&
-                       find_pack_entry_one(sha1, p)) {
+                       find_pack_entry_one(oid->hash, p)) {
                        last_found = p;
                        return 1;
                }
@@ -2719,7 +2792,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
                for (i = 0; i < p->num_objects; i++) {
                        nth_packed_object_oid(&oid, p, i);
                        if (!packlist_find(&to_pack, oid.hash, NULL) &&
-                           !has_sha1_pack_kept_or_nonlocal(oid.hash) &&
+                           !has_sha1_pack_kept_or_nonlocal(&oid) &&
                            !loosened_object_can_be_discarded(&oid, p->mtime))
                                if (force_object_loose(oid.hash, p->mtime))
                                        die("unable to force loose object");
@@ -2817,7 +2890,12 @@ static void get_object_list(int ac, const char **av)
        if (prepare_revision_walk(&revs))
                die("revision walk setup failed");
        mark_edges_uninteresting(&revs, show_edge);
-       traverse_commit_list(&revs, show_commit, show_object, NULL);
+
+       if (!fn_show_object)
+               fn_show_object = show_object;
+       traverse_commit_list_filtered(&filter_options, &revs,
+                                     show_commit, fn_show_object, NULL,
+                                     NULL);
 
        if (unpack_unreachable_expiration) {
                revs.ignore_missing_links = 1;
@@ -2953,6 +3031,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                         N_("use a bitmap index if available to speed up counting objects")),
                OPT_BOOL(0, "write-bitmap-index", &write_bitmap_index,
                         N_("write a bitmap index together with the pack index")),
+               OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
+               { OPTION_CALLBACK, 0, "missing", NULL, N_("action"),
+                 N_("handling for missing objects"), PARSE_OPT_NONEG,
+                 option_parse_missing_action },
+               OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects,
+                        N_("do not pack objects in promisor packfiles")),
                OPT_END(),
        };
 
@@ -2998,6 +3082,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                argv_array_push(&rp, "--unpacked");
        }
 
+       if (exclude_promisor_objects) {
+               use_internal_rev_list = 1;
+               fetch_if_missing = 0;
+               argv_array_push(&rp, "--exclude-promisor-objects");
+       }
+
        if (!reuse_object)
                reuse_delta = 0;
        if (pack_compression_level == -1)
@@ -3029,6 +3119,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        if (!rev_list_all || !rev_list_reflog || !rev_list_index)
                unpack_unreachable_expiration = 0;
 
+       if (filter_options.choice) {
+               if (!pack_to_stdout)
+                       die("cannot use --filter without --stdout.");
+               use_bitmap_index = 0;
+       }
+
        /*
         * "soft" reasons not to use bitmaps - for on-disk repack by default we want
         *