]>
Commit | Line | Data |
---|---|---|
8aece7ff RS |
1 | #!/bin/sh |
2 | ||
3 | test_description='git archive attribute tests' | |
4 | ||
8da0b02d | 5 | TEST_CREATE_REPO_NO_TEMPLATE=1 |
7615cf94 | 6 | TEST_PASSES_SANITIZE_LEAK=true |
8aece7ff RS |
7 | . ./test-lib.sh |
8 | ||
35039ced | 9 | SUBSTFORMAT='%H (%h)%n' |
8aece7ff RS |
10 | |
11 | test_expect_exists() { | |
bed69a6e | 12 | test_expect_${2:-success} " $1 exists" "test -e $1" |
8aece7ff RS |
13 | } |
14 | ||
15 | test_expect_missing() { | |
bed69a6e RS |
16 | test_expect_${2:-success} " $1 does not exist" "test ! -e $1" |
17 | } | |
18 | ||
19 | extract_tar_to_dir () { | |
20 | (mkdir "$1" && cd "$1" && "$TAR" xf -) <"$1.tar" | |
8aece7ff RS |
21 | } |
22 | ||
23 | test_expect_success 'setup' ' | |
24 | echo ignored >ignored && | |
8da0b02d | 25 | mkdir .git/info && |
8aece7ff RS |
26 | echo ignored export-ignore >>.git/info/attributes && |
27 | git add ignored && | |
28 | ||
29 | echo ignored by tree >ignored-by-tree && | |
30 | echo ignored-by-tree export-ignore >.gitattributes && | |
bed69a6e RS |
31 | mkdir ignored-by-tree.d && |
32 | >ignored-by-tree.d/file && | |
33 | echo ignored-by-tree.d export-ignore >>.gitattributes && | |
34 | git add ignored-by-tree ignored-by-tree.d .gitattributes && | |
8aece7ff RS |
35 | |
36 | echo ignored by worktree >ignored-by-worktree && | |
37 | echo ignored-by-worktree export-ignore >.gitattributes && | |
38 | git add ignored-by-worktree && | |
39 | ||
bed69a6e RS |
40 | mkdir excluded-by-pathspec.d && |
41 | >excluded-by-pathspec.d/file && | |
42 | git add excluded-by-pathspec.d && | |
43 | ||
8aece7ff RS |
44 | printf "A\$Format:%s\$O" "$SUBSTFORMAT" >nosubstfile && |
45 | printf "A\$Format:%s\$O" "$SUBSTFORMAT" >substfile1 && | |
46 | printf "A not substituted O" >substfile2 && | |
47 | echo "substfile?" export-subst >>.git/info/attributes && | |
48 | git add nosubstfile substfile1 substfile2 && | |
49 | ||
50 | git commit -m. && | |
51 | ||
8da0b02d ÆAB |
52 | git clone --template= --bare . bare && |
53 | mkdir bare/info && | |
8aece7ff RS |
54 | cp .git/info/attributes bare/info/attributes |
55 | ' | |
56 | ||
57 | test_expect_success 'git archive' ' | |
58 | git archive HEAD >archive.tar && | |
59 | (mkdir archive && cd archive && "$TAR" xf -) <archive.tar | |
60 | ' | |
61 | ||
62 | test_expect_missing archive/ignored | |
63 | test_expect_missing archive/ignored-by-tree | |
bed69a6e RS |
64 | test_expect_missing archive/ignored-by-tree.d |
65 | test_expect_missing archive/ignored-by-tree.d/file | |
8aece7ff | 66 | test_expect_exists archive/ignored-by-worktree |
bed69a6e RS |
67 | test_expect_exists archive/excluded-by-pathspec.d |
68 | test_expect_exists archive/excluded-by-pathspec.d/file | |
69 | ||
70 | test_expect_success 'git archive with pathspec' ' | |
71 | git archive HEAD ":!excluded-by-pathspec.d" >archive-pathspec.tar && | |
72 | extract_tar_to_dir archive-pathspec | |
73 | ' | |
74 | ||
75 | test_expect_missing archive-pathspec/ignored | |
76 | test_expect_missing archive-pathspec/ignored-by-tree | |
77 | test_expect_missing archive-pathspec/ignored-by-tree.d | |
78 | test_expect_missing archive-pathspec/ignored-by-tree.d/file | |
79 | test_expect_exists archive-pathspec/ignored-by-worktree | |
43180940 | 80 | test_expect_missing archive-pathspec/excluded-by-pathspec.d |
bed69a6e RS |
81 | test_expect_missing archive-pathspec/excluded-by-pathspec.d/file |
82 | ||
5ff247ac | 83 | test_expect_success 'git archive with wildcard pathspec' ' |
bed69a6e RS |
84 | git archive HEAD ":!excluded-by-p*" >archive-pathspec-wildcard.tar && |
85 | extract_tar_to_dir archive-pathspec-wildcard | |
86 | ' | |
87 | ||
88 | test_expect_missing archive-pathspec-wildcard/ignored | |
89 | test_expect_missing archive-pathspec-wildcard/ignored-by-tree | |
90 | test_expect_missing archive-pathspec-wildcard/ignored-by-tree.d | |
91 | test_expect_missing archive-pathspec-wildcard/ignored-by-tree.d/file | |
5ff247ac | 92 | test_expect_exists archive-pathspec-wildcard/ignored-by-worktree |
bed69a6e RS |
93 | test_expect_missing archive-pathspec-wildcard/excluded-by-pathspec.d |
94 | test_expect_missing archive-pathspec-wildcard/excluded-by-pathspec.d/file | |
8aece7ff RS |
95 | |
96 | test_expect_success 'git archive with worktree attributes' ' | |
97 | git archive --worktree-attributes HEAD >worktree.tar && | |
98 | (mkdir worktree && cd worktree && "$TAR" xf -) <worktree.tar | |
99 | ' | |
100 | ||
101 | test_expect_missing worktree/ignored | |
102 | test_expect_exists worktree/ignored-by-tree | |
103 | test_expect_missing worktree/ignored-by-worktree | |
104 | ||
f858c646 JH |
105 | test_expect_success 'git archive --worktree-attributes option' ' |
106 | git archive --worktree-attributes --worktree-attributes HEAD >worktree.tar && | |
107 | (mkdir worktree2 && cd worktree2 && "$TAR" xf -) <worktree.tar | |
108 | ' | |
109 | ||
110 | test_expect_missing worktree2/ignored | |
111 | test_expect_exists worktree2/ignored-by-tree | |
112 | test_expect_missing worktree2/ignored-by-worktree | |
113 | ||
8aece7ff RS |
114 | test_expect_success 'git archive vs. bare' ' |
115 | (cd bare && git archive HEAD) >bare-archive.tar && | |
b93e6e36 | 116 | test_cmp_bin archive.tar bare-archive.tar |
8aece7ff RS |
117 | ' |
118 | ||
119 | test_expect_success 'git archive with worktree attributes, bare' ' | |
120 | (cd bare && git archive --worktree-attributes HEAD) >bare-worktree.tar && | |
121 | (mkdir bare-worktree && cd bare-worktree && "$TAR" xf -) <bare-worktree.tar | |
122 | ' | |
123 | ||
124 | test_expect_missing bare-worktree/ignored | |
125 | test_expect_exists bare-worktree/ignored-by-tree | |
126 | test_expect_exists bare-worktree/ignored-by-worktree | |
127 | ||
128 | test_expect_success 'export-subst' ' | |
129 | git log "--pretty=format:A${SUBSTFORMAT}O" HEAD >substfile1.expected && | |
130 | test_cmp nosubstfile archive/nosubstfile && | |
131 | test_cmp substfile1.expected archive/substfile1 && | |
132 | test_cmp substfile2 archive/substfile2 | |
133 | ' | |
134 | ||
96099726 RS |
135 | test_expect_success 'export-subst expands %(describe) once' ' |
136 | echo "\$Format:%(describe)\$" >substfile3 && | |
137 | echo "\$Format:%(describe)\$" >>substfile3 && | |
138 | echo "\$Format:%(describe)${LF}%(describe)\$" >substfile4 && | |
139 | git add substfile[34] && | |
140 | git commit -m export-subst-describe && | |
141 | git tag -m export-subst-describe export-subst-describe && | |
142 | git archive HEAD >archive-describe.tar && | |
143 | extract_tar_to_dir archive-describe && | |
144 | desc=$(git describe) && | |
145 | grep -F "$desc" archive-describe/substfile[34] >substituted && | |
146 | test_line_count = 1 substituted | |
147 | ' | |
148 | ||
8aece7ff | 149 | test_done |