mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
![Taylor Blau](/assets/img/avatar_default.png)
In the previous patch, we made it easy to define other filters that exclude all objects of a certain type. Use that in order to implement bitmap-level filtering for the '--filter=tree:<n>' filter when 'n' is equal to 0. The general case is not helped by bitmaps, since for values of 'n > 0', the object filtering machinery requires a full-blown tree traversal in order to determine the depth of a given tree. Caching this is non-obvious, too, since the same tree object can have a different depth depending on the context (e.g., a tree was moved up in the directory hierarchy between two commits). But, the 'n = 0' case can be helped, and this patch does so. Running p5310.11 in this tree and on master with the kernel, we can see that this case is helped substantially: Test master this tree -------------------------------------------------------------------------------- 5310.11: rev-list count with tree:0 10.68(10.39+0.27) 0.06(0.04+0.01) -99.4% Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
78 lines
2.5 KiB
Bash
Executable file
78 lines
2.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='rev-list combining bitmaps and filters'
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'set up bitmapped repo' '
|
|
# one commit will have bitmaps, the other will not
|
|
test_commit one &&
|
|
test_commit much-larger-blob-one &&
|
|
git repack -adb &&
|
|
test_commit two &&
|
|
test_commit much-larger-blob-two
|
|
'
|
|
|
|
test_expect_success 'filters fallback to non-bitmap traversal' '
|
|
# use a path-based filter, since they are inherently incompatible with
|
|
# bitmaps (i.e., this test will never get confused by later code to
|
|
# combine the features)
|
|
filter=$(echo "!one" | git hash-object -w --stdin) &&
|
|
git rev-list --objects --filter=sparse:oid=$filter HEAD >expect &&
|
|
git rev-list --use-bitmap-index \
|
|
--objects --filter=sparse:oid=$filter HEAD >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'blob:none filter' '
|
|
git rev-list --objects --filter=blob:none HEAD >expect &&
|
|
git rev-list --use-bitmap-index \
|
|
--objects --filter=blob:none HEAD >actual &&
|
|
test_bitmap_traversal expect actual
|
|
'
|
|
|
|
test_expect_success 'blob:none filter with specified blob' '
|
|
git rev-list --objects --filter=blob:none HEAD HEAD:two.t >expect &&
|
|
git rev-list --use-bitmap-index \
|
|
--objects --filter=blob:none HEAD HEAD:two.t >actual &&
|
|
test_bitmap_traversal expect actual
|
|
'
|
|
|
|
test_expect_success 'blob:limit filter' '
|
|
git rev-list --objects --filter=blob:limit=5 HEAD >expect &&
|
|
git rev-list --use-bitmap-index \
|
|
--objects --filter=blob:limit=5 HEAD >actual &&
|
|
test_bitmap_traversal expect actual
|
|
'
|
|
|
|
test_expect_success 'blob:limit filter with specified blob' '
|
|
git rev-list --objects --filter=blob:limit=5 \
|
|
HEAD HEAD:much-larger-blob-two.t >expect &&
|
|
git rev-list --use-bitmap-index \
|
|
--objects --filter=blob:limit=5 \
|
|
HEAD HEAD:much-larger-blob-two.t >actual &&
|
|
test_bitmap_traversal expect actual
|
|
'
|
|
|
|
test_expect_success 'tree:0 filter' '
|
|
git rev-list --objects --filter=tree:0 HEAD >expect &&
|
|
git rev-list --use-bitmap-index \
|
|
--objects --filter=tree:0 HEAD >actual &&
|
|
test_bitmap_traversal expect actual
|
|
'
|
|
|
|
test_expect_success 'tree:0 filter with specified blob, tree' '
|
|
git rev-list --objects --filter=tree:0 HEAD HEAD:two.t >expect &&
|
|
git rev-list --use-bitmap-index \
|
|
--objects --filter=tree:0 HEAD HEAD:two.t >actual &&
|
|
test_bitmap_traversal expect actual
|
|
'
|
|
|
|
test_expect_success 'tree:1 filter' '
|
|
git rev-list --objects --filter=tree:1 HEAD >expect &&
|
|
git rev-list --use-bitmap-index \
|
|
--objects --filter=tree:1 HEAD >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|