diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-11-08 07:04:42 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-11-08 07:04:42 +0100 |
commit | 8ed4eb753881cf3a695cbe531c22698ca222ff0f (patch) | |
tree | 28e7f24a60f6b4a854026b8fd1bfeb9387b2e250 /pack-bitmap.c | |
parent | Merge branch 'ps/leakfixes' (diff) | |
parent | pack-bitmap: drop --unpacked non-commit objects from results (diff) | |
download | git-8ed4eb753881cf3a695cbe531c22698ca222ff0f.tar.xz git-8ed4eb753881cf3a695cbe531c22698ca222ff0f.zip |
Merge branch 'tb/rev-list-unpacked-fix'
"git rev-list --unpacked --objects" failed to exclude packed
non-commit objects, which has been corrected.
* tb/rev-list-unpacked-fix:
pack-bitmap: drop --unpacked non-commit objects from results
list-objects: drop --unpacked non-commit objects from results
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r-- | pack-bitmap.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c index ca8319b87c..0260890341 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1666,6 +1666,30 @@ static int can_filter_bitmap(struct list_objects_filter_options *filter) return !filter_bitmap(NULL, NULL, NULL, filter); } + +static void filter_packed_objects_from_bitmap(struct bitmap_index *bitmap_git, + struct bitmap *result) +{ + struct eindex *eindex = &bitmap_git->ext_index; + uint32_t objects_nr; + size_t i, pos; + + objects_nr = bitmap_num_objects(bitmap_git); + pos = objects_nr / BITS_IN_EWORD; + + if (pos > result->word_alloc) + pos = result->word_alloc; + + memset(result->words, 0x00, sizeof(eword_t) * pos); + for (i = pos * BITS_IN_EWORD; i < objects_nr; i++) + bitmap_unset(result, i); + + for (i = 0; i < eindex->count; ++i) { + if (has_object_pack(&eindex->objects[i]->oid)) + bitmap_unset(result, objects_nr + i); + } +} + struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, int filter_provided_objects) { @@ -1788,6 +1812,9 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, wants_bitmap, &revs->filter); + if (revs->unpacked) + filter_packed_objects_from_bitmap(bitmap_git, wants_bitmap); + bitmap_git->result = wants_bitmap; bitmap_git->haves = haves_bitmap; |