@@ -7,11 +7,15 @@ test_description='git archive attribute tests'
77SUBSTFORMAT=' %H (%h)%n'
88
99test_expect_exists () {
10- test_expect_success " $1 exists" " test -e $1 "
10+ test_expect_ ${2 :- success} " $1 exists" " test -e $1 "
1111}
1212
1313test_expect_missing () {
14- test_expect_success " $1 does not exist" " test ! -e $1 "
14+ test_expect_${2:- success} " $1 does not exist" " test ! -e $1 "
15+ }
16+
17+ extract_tar_to_dir () {
18+ (mkdir " $1 " && cd " $1 " && " $TAR " xf -) < " $1 .tar"
1519}
1620
1721test_expect_success ' setup' '
@@ -21,12 +25,19 @@ test_expect_success 'setup' '
2125
2226 echo ignored by tree >ignored-by-tree &&
2327 echo ignored-by-tree export-ignore >.gitattributes &&
24- git add ignored-by-tree .gitattributes &&
28+ mkdir ignored-by-tree.d &&
29+ >ignored-by-tree.d/file &&
30+ echo ignored-by-tree.d export-ignore >>.gitattributes &&
31+ git add ignored-by-tree ignored-by-tree.d .gitattributes &&
2532
2633 echo ignored by worktree >ignored-by-worktree &&
2734 echo ignored-by-worktree export-ignore >.gitattributes &&
2835 git add ignored-by-worktree &&
2936
37+ mkdir excluded-by-pathspec.d &&
38+ >excluded-by-pathspec.d/file &&
39+ git add excluded-by-pathspec.d &&
40+
3041 printf "A\$Format:%s\$O" "$SUBSTFORMAT" >nosubstfile &&
3142 printf "A\$Format:%s\$O" "$SUBSTFORMAT" >substfile1 &&
3243 printf "A not substituted O" >substfile2 &&
@@ -46,7 +57,37 @@ test_expect_success 'git archive' '
4657
4758test_expect_missing archive/ignored
4859test_expect_missing archive/ignored-by-tree
60+ test_expect_missing archive/ignored-by-tree.d
61+ test_expect_missing archive/ignored-by-tree.d/file
4962test_expect_exists archive/ignored-by-worktree
63+ test_expect_exists archive/excluded-by-pathspec.d
64+ test_expect_exists archive/excluded-by-pathspec.d/file
65+
66+ test_expect_success ' git archive with pathspec' '
67+ git archive HEAD ":!excluded-by-pathspec.d" >archive-pathspec.tar &&
68+ extract_tar_to_dir archive-pathspec
69+ '
70+
71+ test_expect_missing archive-pathspec/ignored
72+ test_expect_missing archive-pathspec/ignored-by-tree
73+ test_expect_missing archive-pathspec/ignored-by-tree.d
74+ test_expect_missing archive-pathspec/ignored-by-tree.d/file
75+ test_expect_exists archive-pathspec/ignored-by-worktree
76+ test_expect_missing archive-pathspec/excluded-by-pathspec.d failure
77+ test_expect_missing archive-pathspec/excluded-by-pathspec.d/file
78+
79+ test_expect_failure ' git archive with wildcard pathspec' '
80+ git archive HEAD ":!excluded-by-p*" >archive-pathspec-wildcard.tar &&
81+ extract_tar_to_dir archive-pathspec-wildcard
82+ '
83+
84+ test_expect_missing archive-pathspec-wildcard/ignored
85+ test_expect_missing archive-pathspec-wildcard/ignored-by-tree
86+ test_expect_missing archive-pathspec-wildcard/ignored-by-tree.d
87+ test_expect_missing archive-pathspec-wildcard/ignored-by-tree.d/file
88+ test_expect_exists archive-pathspec-wildcard/ignored-by-worktree failure
89+ test_expect_missing archive-pathspec-wildcard/excluded-by-pathspec.d
90+ test_expect_missing archive-pathspec-wildcard/excluded-by-pathspec.d/file
5091
5192test_expect_success ' git archive with worktree attributes' '
5293 git archive --worktree-attributes HEAD >worktree.tar &&
0 commit comments