Merge pull request #285 from dscho/readme
[git/mingw/4msysgit.git] / t / t5001-archive-attr.sh
blobb04d955bfa8229a9c864ad53d1f9f1ec06260637
1 #!/bin/sh
3 test_description='git archive attribute tests'
5 . ./test-lib.sh
7 SUBSTFORMAT='%H (%h)%n'
9 test_expect_exists() {
10 test_expect_success " $1 exists" "test -e $1"
13 test_expect_missing() {
14 test_expect_success " $1 does not exist" "test ! -e $1"
17 test_expect_success 'setup' '
18 echo ignored >ignored &&
19 echo ignored export-ignore >>.git/info/attributes &&
20 git add ignored &&
22 echo ignored by tree >ignored-by-tree &&
23 echo ignored-by-tree export-ignore >.gitattributes &&
24 git add ignored-by-tree .gitattributes &&
26 echo ignored by worktree >ignored-by-worktree &&
27 echo ignored-by-worktree export-ignore >.gitattributes &&
28 git add ignored-by-worktree &&
30 printf "A\$Format:%s\$O" "$SUBSTFORMAT" >nosubstfile &&
31 printf "A\$Format:%s\$O" "$SUBSTFORMAT" >substfile1 &&
32 printf "A not substituted O" >substfile2 &&
33 echo "substfile?" export-subst >>.git/info/attributes &&
34 git add nosubstfile substfile1 substfile2 &&
36 git commit -m. &&
38 git clone --bare . bare &&
39 cp .git/info/attributes bare/info/attributes
42 test_expect_success 'git archive' '
43 git archive HEAD >archive.tar &&
44 (mkdir archive && cd archive && "$TAR" xf -) <archive.tar
47 test_expect_missing archive/ignored
48 test_expect_missing archive/ignored-by-tree
49 test_expect_exists archive/ignored-by-worktree
51 test_expect_success 'git archive with worktree attributes' '
52 git archive --worktree-attributes HEAD >worktree.tar &&
53 (mkdir worktree && cd worktree && "$TAR" xf -) <worktree.tar
56 test_expect_missing worktree/ignored
57 test_expect_exists worktree/ignored-by-tree
58 test_expect_missing worktree/ignored-by-worktree
60 test_expect_success 'git archive --worktree-attributes option' '
61 git archive --worktree-attributes --worktree-attributes HEAD >worktree.tar &&
62 (mkdir worktree2 && cd worktree2 && "$TAR" xf -) <worktree.tar
65 test_expect_missing worktree2/ignored
66 test_expect_exists worktree2/ignored-by-tree
67 test_expect_missing worktree2/ignored-by-worktree
69 test_expect_success 'git archive vs. bare' '
70 (cd bare && git archive HEAD) >bare-archive.tar &&
71 test_cmp_bin archive.tar bare-archive.tar
74 test_expect_success 'git archive with worktree attributes, bare' '
75 (cd bare && git archive --worktree-attributes HEAD) >bare-worktree.tar &&
76 (mkdir bare-worktree && cd bare-worktree && "$TAR" xf -) <bare-worktree.tar
79 test_expect_missing bare-worktree/ignored
80 test_expect_exists bare-worktree/ignored-by-tree
81 test_expect_exists bare-worktree/ignored-by-worktree
83 test_expect_success 'export-subst' '
84 git log "--pretty=format:A${SUBSTFORMAT}O" HEAD >substfile1.expected &&
85 test_cmp nosubstfile archive/nosubstfile &&
86 test_cmp substfile1.expected archive/substfile1 &&
87 test_cmp substfile2 archive/substfile2
90 test_done