]>
Commit | Line | Data |
---|---|---|
e03f928e JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='rev-list combining bitmaps and filters' | |
4 | . ./test-lib.sh | |
ddfe9006 | 5 | . "$TEST_DIRECTORY"/lib-bitmap.sh |
e03f928e | 6 | |
a96015a5 TB |
7 | TEST_PASSES_SANITIZE_LEAK=true |
8 | ||
e03f928e JK |
9 | test_expect_success 'set up bitmapped repo' ' |
10 | # one commit will have bitmaps, the other will not | |
11 | test_commit one && | |
84243da1 | 12 | test_commit much-larger-blob-one && |
e03f928e | 13 | git repack -adb && |
84243da1 | 14 | test_commit two && |
7ab6aafa PS |
15 | test_commit much-larger-blob-two && |
16 | git tag tag | |
e03f928e JK |
17 | ' |
18 | ||
19 | test_expect_success 'filters fallback to non-bitmap traversal' ' | |
20 | # use a path-based filter, since they are inherently incompatible with | |
21 | # bitmaps (i.e., this test will never get confused by later code to | |
22 | # combine the features) | |
23 | filter=$(echo "!one" | git hash-object -w --stdin) && | |
24 | git rev-list --objects --filter=sparse:oid=$filter HEAD >expect && | |
25 | git rev-list --use-bitmap-index \ | |
26 | --objects --filter=sparse:oid=$filter HEAD >actual && | |
27 | test_cmp expect actual | |
28 | ' | |
29 | ||
4f3bd560 JK |
30 | test_expect_success 'blob:none filter' ' |
31 | git rev-list --objects --filter=blob:none HEAD >expect && | |
32 | git rev-list --use-bitmap-index \ | |
33 | --objects --filter=blob:none HEAD >actual && | |
34 | test_bitmap_traversal expect actual | |
35 | ' | |
36 | ||
37 | test_expect_success 'blob:none filter with specified blob' ' | |
38 | git rev-list --objects --filter=blob:none HEAD HEAD:two.t >expect && | |
39 | git rev-list --use-bitmap-index \ | |
40 | --objects --filter=blob:none HEAD HEAD:two.t >actual && | |
41 | test_bitmap_traversal expect actual | |
42 | ' | |
43 | ||
84243da1 JK |
44 | test_expect_success 'blob:limit filter' ' |
45 | git rev-list --objects --filter=blob:limit=5 HEAD >expect && | |
46 | git rev-list --use-bitmap-index \ | |
47 | --objects --filter=blob:limit=5 HEAD >actual && | |
48 | test_bitmap_traversal expect actual | |
49 | ' | |
50 | ||
51 | test_expect_success 'blob:limit filter with specified blob' ' | |
52 | git rev-list --objects --filter=blob:limit=5 \ | |
53 | HEAD HEAD:much-larger-blob-two.t >expect && | |
54 | git rev-list --use-bitmap-index \ | |
55 | --objects --filter=blob:limit=5 \ | |
56 | HEAD HEAD:much-larger-blob-two.t >actual && | |
57 | test_bitmap_traversal expect actual | |
58 | ' | |
59 | ||
b0a8d482 TB |
60 | test_expect_success 'tree:0 filter' ' |
61 | git rev-list --objects --filter=tree:0 HEAD >expect && | |
62 | git rev-list --use-bitmap-index \ | |
63 | --objects --filter=tree:0 HEAD >actual && | |
64 | test_bitmap_traversal expect actual | |
65 | ' | |
66 | ||
67 | test_expect_success 'tree:0 filter with specified blob, tree' ' | |
68 | git rev-list --objects --filter=tree:0 HEAD HEAD:two.t >expect && | |
69 | git rev-list --use-bitmap-index \ | |
70 | --objects --filter=tree:0 HEAD HEAD:two.t >actual && | |
71 | test_bitmap_traversal expect actual | |
72 | ' | |
73 | ||
74 | test_expect_success 'tree:1 filter' ' | |
75 | git rev-list --objects --filter=tree:1 HEAD >expect && | |
76 | git rev-list --use-bitmap-index \ | |
77 | --objects --filter=tree:1 HEAD >actual && | |
78 | test_cmp expect actual | |
79 | ' | |
80 | ||
7ab6aafa PS |
81 | test_expect_success 'object:type filter' ' |
82 | git rev-list --objects --filter=object:type=tag tag >expect && | |
83 | git rev-list --use-bitmap-index \ | |
84 | --objects --filter=object:type=tag tag >actual && | |
85 | test_cmp expect actual && | |
86 | ||
87 | git rev-list --objects --filter=object:type=commit tag >expect && | |
88 | git rev-list --use-bitmap-index \ | |
89 | --objects --filter=object:type=commit tag >actual && | |
90 | test_bitmap_traversal expect actual && | |
91 | ||
92 | git rev-list --objects --filter=object:type=tree tag >expect && | |
93 | git rev-list --use-bitmap-index \ | |
94 | --objects --filter=object:type=tree tag >actual && | |
95 | test_bitmap_traversal expect actual && | |
96 | ||
97 | git rev-list --objects --filter=object:type=blob tag >expect && | |
98 | git rev-list --use-bitmap-index \ | |
99 | --objects --filter=object:type=blob tag >actual && | |
100 | test_bitmap_traversal expect actual | |
101 | ' | |
102 | ||
9cf68b27 PS |
103 | test_expect_success 'object:type filter with --filter-provided-objects' ' |
104 | git rev-list --objects --filter-provided-objects --filter=object:type=tag tag >expect && | |
105 | git rev-list --use-bitmap-index \ | |
106 | --objects --filter-provided-objects --filter=object:type=tag tag >actual && | |
107 | test_cmp expect actual && | |
108 | ||
109 | git rev-list --objects --filter-provided-objects --filter=object:type=commit tag >expect && | |
110 | git rev-list --use-bitmap-index \ | |
111 | --objects --filter-provided-objects --filter=object:type=commit tag >actual && | |
112 | test_bitmap_traversal expect actual && | |
113 | ||
114 | git rev-list --objects --filter-provided-objects --filter=object:type=tree tag >expect && | |
115 | git rev-list --use-bitmap-index \ | |
116 | --objects --filter-provided-objects --filter=object:type=tree tag >actual && | |
117 | test_bitmap_traversal expect actual && | |
118 | ||
119 | git rev-list --objects --filter-provided-objects --filter=object:type=blob tag >expect && | |
120 | git rev-list --use-bitmap-index \ | |
121 | --objects --filter-provided-objects --filter=object:type=blob tag >actual && | |
122 | test_bitmap_traversal expect actual | |
123 | ' | |
124 | ||
169a15eb PS |
125 | test_expect_success 'combine filter' ' |
126 | git rev-list --objects --filter=blob:limit=1000 --filter=object:type=blob tag >expect && | |
127 | git rev-list --use-bitmap-index \ | |
128 | --objects --filter=blob:limit=1000 --filter=object:type=blob tag >actual && | |
129 | test_bitmap_traversal expect actual | |
130 | ' | |
131 | ||
9cf68b27 PS |
132 | test_expect_success 'combine filter with --filter-provided-objects' ' |
133 | git rev-list --objects --filter-provided-objects --filter=blob:limit=1000 --filter=object:type=blob tag >expect && | |
134 | git rev-list --use-bitmap-index \ | |
135 | --objects --filter-provided-objects --filter=blob:limit=1000 --filter=object:type=blob tag >actual && | |
136 | test_bitmap_traversal expect actual && | |
137 | ||
138 | git cat-file --batch-check="%(objecttype) %(objectsize)" <actual >objects && | |
139 | while read objecttype objectsize | |
140 | do | |
141 | test "$objecttype" = blob || return 1 | |
142 | test "$objectsize" -le 1000 || return 1 | |
143 | done <objects | |
144 | ' | |
145 | ||
7b3c8e9f TB |
146 | test_expect_success 'bitmap traversal with --unpacked' ' |
147 | git repack -adb && | |
148 | test_commit unpacked && | |
149 | ||
150 | git rev-list --objects --no-object-names unpacked^.. >expect.raw && | |
151 | sort expect.raw >expect && | |
152 | ||
153 | git rev-list --use-bitmap-index --objects --all --unpacked >actual.raw && | |
154 | sort actual.raw >actual && | |
155 | ||
156 | test_cmp expect actual | |
157 | ' | |
158 | ||
e03f928e | 159 | test_done |