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