path: root/t/
diff options
authorNguyễn Thái Ngọc Duy <>2014-09-21 03:55:06 (GMT)
committerJunio C Hamano <>2014-09-22 19:04:29 (GMT)
commited22b4173bd8d6dbce6236480bd30a63dd54834e (patch)
tree11c8cbd8ce490c049574cb21c4a37e75d264dfd6 /t/
parentd31f3ad23dd1aee3c3e1015a43b02b995c01a9a1 (diff)
archive: support filtering paths with glob
This patch fixes two problems with using :(glob) (or even "*.c" without ":(glob)"). The first one is we forgot to turn on the 'recursive' flag in struct pathspec. Without that, tree_entry_interesting() will not mark potential directories "interesting" so that it can confirm whether those directories have anything matching the pathspec. The marking directories interesting has a side effect that we need to walk inside a directory to realize that there's nothing interested in there. By that time, 'archive' code has already written the (empty) directory down. That means lots of empty directories in the result archive. This problem is fixed by lazily writing directories down when we know they are actually needed. There is a theoretical bug in this implementation: we can't write empty trees/directories that match that pathspec. path_exists() is also made stricter in order to detect non-matching pathspec because when this 'recursive' flag is on, we most likely match some directories. The easiest way is not consider any directories "matched". Noticed-by: Peter Wu <> Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 14 insertions, 0 deletions
diff --git a/t/ b/t/
index 05f011d..c9abab4 100755
--- a/t/
+++ b/t/
@@ -300,4 +300,18 @@ test_expect_success GZIP 'remote tar.gz can be disabled' '
+test_expect_success 'archive and :(glob)' '
+ git archive -v HEAD -- ":(glob)**/sh" >/dev/null 2>actual &&
+ cat >expect <<EOF &&
+ test_cmp expect actual
+test_expect_success 'catch non-matching pathspec' '
+ test_must_fail git archive -v HEAD -- "*.abc" >/dev/null