path: root/t/
diff options
authorMatthew DeVore <>2019-06-27 22:54:12 (GMT)
committerJunio C Hamano <>2019-06-28 15:41:53 (GMT)
commit489fc9ee718b7c8594f17b55f090ac5292c655e1 (patch)
tree07a52471c29dea788f32700918402182c98f7c6c /t/
parentc2694952e33764818983fa247dcee72113c6ac6a (diff)
list-objects-filter-options: allow mult. --filter
Allow combining of multiple filters by simply repeating the --filter flag. Before this patch, the user had to combine them in a single flag somewhat awkwardly (e.g. --filter=combine:FOO+BAR), including URL-encoding the individual filters. To make this work, in the --filter flag parsing callback, rather than error out when we detect that the filter_options struct is already populated, we modify it in-place to contain the added sub-filter. The existing sub-filter becomes the lhs of the combined filter, and the next sub-filter becomes the rhs. We also have to URL-encode the LHS and RHS sub-filters. We can simplify the operation if the LHS is already a combine: filter. In that case, we just append the URL-encoded RHS sub-filter to the LHS spec to get the new spec. Helped-by: Emily Shaffer <> Helped-by: Jeff Hostetler <> Helped-by: Jeff King <> Helped-by: Junio C Hamano <> Signed-off-by: Matthew DeVore <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 19 insertions, 0 deletions
diff --git a/t/ b/t/
index b91ef54..32b7d72 100755
--- a/t/
+++ b/t/
@@ -208,6 +208,25 @@ test_expect_success 'use fsck before and after manually fetching a missing subtr
test_cmp unique_types.expected unique_types.observed
+test_expect_success 'implicitly construct combine: filter with repeated flags' '
+ GIT_TRACE=$(pwd)/trace git clone --bare \
+ --filter=blob:none --filter=tree:1 \
+ "file://$(pwd)/srv.bare" pc2 &&
+ grep "trace:.* git pack-objects .*--filter=combine:blob:none+tree:1" \
+ trace &&
+ git -C pc2 rev-list --objects --missing=allow-any HEAD >objects &&
+ # We should have gotten some root trees.
+ grep " $" objects &&
+ # Should not have gotten any non-root trees or blobs.
+ ! grep " ." objects &&
+ xargs -n 1 git -C pc2 cat-file -t <objects >types &&
+ sort -u types >unique_types.actual &&
+ test_write_lines commit tree >unique_types.expected &&
+ test_cmp unique_types.expected unique_types.actual
test_expect_success 'partial clone fetches blobs pointed to by refs even if normally filtered out' '
rm -rf src dst &&
git init src &&