chiark / gitweb /
test suite: gitattributes: new test, still wip
[dgit.git] / tests / tests / gitattributes
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-dependencies bsdgames
6 t-tstunt-parsechangelog
7
8 t-archive-none example
9 v=1.0
10 t-worktree $v
11
12 cd $p
13
14 : ----- convert to "3.0 (quilt)"
15
16 rm -rf .git
17 tar --exclude=debian -C .. -zcf ../${p}_${v}.orig.tar.gz $p
18 dch -v 1.0-1 -m convert
19 mkdir -p debian/source
20 echo '3.0 (quilt)' >debian/source/format
21
22 v=1.0-1
23
24 : ----- make everything break -----
25
26 mkdir af
27
28 addpatch () {
29         pname=$1
30         cat >../editor.pl <<END
31                 next if m/^$/..0;
32                 s{^(description:).*}{\$1 dgit test patch $pname}i;
33                 \$_='' if m/^ /;
34 END
35         EDITOR="perl -pi $tmp/editor.pl" dpkg-source -iX --commit . $pname
36         test -f debian/patches/$pname
37 }
38
39 badattr1 () {
40         local filename=$1
41         local attrspec=$2
42         echo >>af/$filename "Test file with $attrspec"
43         printf >>af/$filename 'crlf: \r\n'
44         echo >>af/$filename 'id $Id: $'
45         echo >>af/$filename 'id $Id: SPLARK $'
46         echo >>.gitattributes "af/$filename" "$attrspec"
47 }
48
49 badattr () {
50         attrname=$1; shift
51         badattr1 $attrname-set $attrname
52         badattr1 $attrname-unset -$attrname
53         badattr1 $attrname-unspec \!$attrname
54         local val
55         for val in "$@"; do
56                 badattr1 $attrname=$val $attrname=$val
57         done
58 }
59
60 # xxx want to make each of these files into a quilt patch
61
62 t-git-config core.eol crlf
63
64 badattr text auto
65 badattr eol lf crlf
66 badattr ident
67
68 t-git-config filter.dgit-test-crazy-f.smudge '/usr/games/rot13 2'
69 t-git-config filter.dgit-test-crazy-f.clean  '/usr/games/rot13 24'
70 t-git-config filter.dgit-test-crazy-f.requrired true
71
72 badattr filter dgit-test-crazy-f
73
74 badattr diff
75 badattr merge text binary union
76 badattr whitespace
77 badattr export-ignore
78 badattr export-subst
79 badattr delta
80 badattr encoding no-such-encoding
81
82 mv af ../af.aside
83 addpatch gitattrs
84
85 mv ../af.aside af
86 addpatch files
87
88 sha256sum af/* >sums
89 addpatch sums
90
91 dpkg-source -b .
92
93 cd ..
94 mkdir $p.import
95 cd $p.import
96 git init
97
98 #t-dgit --force-import-gitapply-absurd import-dsc ../${p}_${v}.dsc +import
99 t-dgit import-dsc ../${p}_${v}.dsc +import
100
101 git checkout import
102
103 for f in af/*; do
104         git cat-file blob "refs/heads/import:$f" | sha256sum | \
105                 sed -e 's#-$#'$f'#' \
106                 >>../sums
107 done
108
109 diff -U0 sums ../sums
110
111 #t-ok