]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap: implement combined filter
authorPatrick Steinhardt <ps@pks.im>
Mon, 19 Apr 2021 11:47:02 +0000 (13:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Apr 2021 21:09:11 +0000 (14:09 -0700)
When the user has multiple objects filters specified, then this is
internally represented by having a "combined" filter. These combined
filters aren't yet supported by bitmap indices and can thus not be
accelerated.

Fix this by implementing support for these combined filters. The
implementation is quite trivial: when there's a combined filter, we
simply recurse into `filter_bitmap()` for all of the sub-filters.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-bitmap.c
t/t6113-rev-list-bitmap-filters.sh

index cd3f5c433eab0427eb1b16a1149ca366d8c305b8..7ce3ede7e478c8937888e7c8b712947cca40d46a 100644 (file)
@@ -966,6 +966,16 @@ static int filter_bitmap(struct bitmap_index *bitmap_git,
                return 0;
        }
 
+       if (filter->choice == LOFC_COMBINE) {
+               int i;
+               for (i = 0; i < filter->sub_nr; i++) {
+                       if (filter_bitmap(bitmap_git, tip_objects, to_filter,
+                                         &filter->sub[i]) < 0)
+                               return -1;
+               }
+               return 0;
+       }
+
        /* filter choice not handled */
        return -1;
 }
index fb66735ac835283d7d68c503a760659fa7ab7052..cb9db7df6f1c7935a51dbcbdc00adf1304dffe3a 100755 (executable)
@@ -98,4 +98,11 @@ test_expect_success 'object:type filter' '
        test_bitmap_traversal expect actual
 '
 
+test_expect_success 'combine filter' '
+       git rev-list --objects --filter=blob:limit=1000 --filter=object:type=blob tag >expect &&
+       git rev-list --use-bitmap-index \
+                    --objects --filter=blob:limit=1000 --filter=object:type=blob tag >actual &&
+       test_bitmap_traversal expect actual
+'
+
 test_done