unicode: update the width tables to Unicode 15
[alt-git.git] / t / t5001-archive-attr.sh
blob04d300eeda760033c0e72beb2aee1235c664c457
1 #!/bin/sh
3 test_description='git archive attribute tests'
5 TEST_CREATE_REPO_NO_TEMPLATE=1
6 TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
9 SUBSTFORMAT='%H (%h)%n'
11 test_expect_exists() {
12 test_expect_${2:-success} " $1 exists" "test -e $1"
15 test_expect_missing() {
16 test_expect_${2:-success} " $1 does not exist" "test ! -e $1"
19 extract_tar_to_dir () {
20 (mkdir "$1" && cd "$1" && "$TAR" xf -) <"$1.tar"
23 test_expect_success 'setup' '
24 echo ignored >ignored &&
25 mkdir .git/info &&
26 echo ignored export-ignore >>.git/info/attributes &&
27 git add ignored &&
29 echo ignored by tree >ignored-by-tree &&
30 echo ignored-by-tree export-ignore >.gitattributes &&
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 &&
36 echo ignored by worktree >ignored-by-worktree &&
37 echo ignored-by-worktree export-ignore >.gitattributes &&
38 git add ignored-by-worktree &&
40 mkdir excluded-by-pathspec.d &&
41 >excluded-by-pathspec.d/file &&
42 git add excluded-by-pathspec.d &&
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 &&
50 git commit -m. &&
52 git clone --template= --bare . bare &&
53 mkdir bare/info &&
54 cp .git/info/attributes bare/info/attributes
57 test_expect_success 'git archive' '
58 git archive HEAD >archive.tar &&
59 (mkdir archive && cd archive && "$TAR" xf -) <archive.tar
62 test_expect_missing archive/ignored
63 test_expect_missing archive/ignored-by-tree
64 test_expect_missing archive/ignored-by-tree.d
65 test_expect_missing archive/ignored-by-tree.d/file
66 test_expect_exists archive/ignored-by-worktree
67 test_expect_exists archive/excluded-by-pathspec.d
68 test_expect_exists archive/excluded-by-pathspec.d/file
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
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
80 test_expect_missing archive-pathspec/excluded-by-pathspec.d
81 test_expect_missing archive-pathspec/excluded-by-pathspec.d/file
83 test_expect_success 'git archive with wildcard pathspec' '
84 git archive HEAD ":!excluded-by-p*" >archive-pathspec-wildcard.tar &&
85 extract_tar_to_dir archive-pathspec-wildcard
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
92 test_expect_exists archive-pathspec-wildcard/ignored-by-worktree
93 test_expect_missing archive-pathspec-wildcard/excluded-by-pathspec.d
94 test_expect_missing archive-pathspec-wildcard/excluded-by-pathspec.d/file
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
101 test_expect_missing worktree/ignored
102 test_expect_exists worktree/ignored-by-tree
103 test_expect_missing worktree/ignored-by-worktree
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
110 test_expect_missing worktree2/ignored
111 test_expect_exists worktree2/ignored-by-tree
112 test_expect_missing worktree2/ignored-by-worktree
114 test_expect_success 'git archive vs. bare' '
115 (cd bare && git archive HEAD) >bare-archive.tar &&
116 test_cmp_bin archive.tar bare-archive.tar
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
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
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
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
149 test_done