The eleventh batch
[git/gitster.git] / t / t2082-parallel-checkout-attributes.sh
blobd02d6a555040c8fde2eb13ba1a990f1d6ce93fca
1 #!/bin/sh
3 test_description='parallel-checkout: attributes
5 Verify that parallel-checkout correctly creates files that require
6 conversions, as specified in .gitattributes. The main point here is
7 to check that the conv_attr data is correctly sent to the workers
8 and that it contains sufficient information to smudge files
9 properly (without access to the index or attribute stack).
12 TEST_NO_CREATE_REPO=1
13 TEST_PASSES_SANITIZE_LEAK=true
14 . ./test-lib.sh
15 . "$TEST_DIRECTORY/lib-parallel-checkout.sh"
16 . "$TEST_DIRECTORY/lib-encoding.sh"
18 test_expect_success 'parallel-checkout with ident' '
19 set_checkout_config 2 0 &&
20 git init ident &&
22 cd ident &&
23 echo "A ident" >.gitattributes &&
24 echo "\$Id\$" >A &&
25 echo "\$Id\$" >B &&
26 git add -A &&
27 git commit -m id &&
29 rm A B &&
30 test_checkout_workers 2 git reset --hard &&
31 hexsz=$(test_oid hexsz) &&
32 grep -E "\\\$Id: [0-9a-f]{$hexsz} \\\$" A &&
33 grep "\\\$Id\\\$" B
37 test_expect_success ICONV 'parallel-checkout with re-encoding' '
38 set_checkout_config 2 0 &&
39 git init encoding &&
41 cd encoding &&
42 echo text >utf8-text &&
43 write_utf16 <utf8-text >utf16-text &&
45 echo "A working-tree-encoding=UTF-16" >.gitattributes &&
46 cp utf16-text A &&
47 cp utf8-text B &&
48 git add A B .gitattributes &&
49 git commit -m encoding &&
51 # Check that A is stored in UTF-8
52 git cat-file -p :A >A.internal &&
53 test_cmp_bin utf8-text A.internal &&
55 rm A B &&
56 test_checkout_workers 2 git checkout A B &&
58 # Check that A (and only A) is re-encoded during checkout
59 test_cmp_bin utf16-text A &&
60 test_cmp_bin utf8-text B
64 test_expect_success 'parallel-checkout with eol conversions' '
65 set_checkout_config 2 0 &&
66 git init eol &&
68 cd eol &&
69 printf "multi\r\nline\r\ntext" >crlf-text &&
70 printf "multi\nline\ntext" >lf-text &&
72 git config core.autocrlf false &&
73 echo "A eol=crlf" >.gitattributes &&
74 cp crlf-text A &&
75 cp lf-text B &&
76 git add A B .gitattributes &&
77 git commit -m eol &&
79 # Check that A is stored with LF format
80 git cat-file -p :A >A.internal &&
81 test_cmp_bin lf-text A.internal &&
83 rm A B &&
84 test_checkout_workers 2 git checkout A B &&
86 # Check that A (and only A) is converted to CRLF during checkout
87 test_cmp_bin crlf-text A &&
88 test_cmp_bin lf-text B
92 # Entries that require an external filter are not eligible for parallel
93 # checkout. Check that both the parallel-eligible and non-eligible entries are
94 # properly written in a single checkout operation.
96 test_expect_success 'parallel-checkout and external filter' '
97 set_checkout_config 2 0 &&
98 git init filter &&
100 cd filter &&
101 write_script <<-\EOF rot13.sh &&
102 tr \
103 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
104 "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
107 git config filter.rot13.clean "\"$(pwd)/rot13.sh\"" &&
108 git config filter.rot13.smudge "\"$(pwd)/rot13.sh\"" &&
109 git config filter.rot13.required true &&
111 echo abcd >original &&
112 echo nopq >rot13 &&
114 echo "A filter=rot13" >.gitattributes &&
115 cp original A &&
116 cp original B &&
117 cp original C &&
118 git add A B C .gitattributes &&
119 git commit -m filter &&
121 # Check that A (and only A) was cleaned
122 git cat-file -p :A >A.internal &&
123 test_cmp rot13 A.internal &&
124 git cat-file -p :B >B.internal &&
125 test_cmp original B.internal &&
126 git cat-file -p :C >C.internal &&
127 test_cmp original C.internal &&
129 rm A B C *.internal &&
130 test_checkout_workers 2 git checkout A B C &&
132 # Check that A (and only A) was smudged during checkout
133 test_cmp original A &&
134 test_cmp original B &&
135 test_cmp original C
139 # The delayed queue is independent from the parallel queue, and they should be
140 # able to work together in the same checkout process.
142 test_expect_success 'parallel-checkout and delayed checkout' '
143 test_config_global filter.delay.process \
144 "test-tool rot13-filter --always-delay --log=\"$(pwd)/delayed.log\" clean smudge delay" &&
145 test_config_global filter.delay.required true &&
147 echo "abcd" >original &&
148 echo "nopq" >rot13 &&
150 git init delayed &&
152 cd delayed &&
153 echo "*.d filter=delay" >.gitattributes &&
154 cp ../original W.d &&
155 cp ../original X.d &&
156 cp ../original Y &&
157 cp ../original Z &&
158 git add -A &&
159 git commit -m delayed &&
161 # Check that *.d files were cleaned
162 git cat-file -p :W.d >W.d.internal &&
163 test_cmp W.d.internal ../rot13 &&
164 git cat-file -p :X.d >X.d.internal &&
165 test_cmp X.d.internal ../rot13 &&
166 git cat-file -p :Y >Y.internal &&
167 test_cmp Y.internal ../original &&
168 git cat-file -p :Z >Z.internal &&
169 test_cmp Z.internal ../original &&
171 rm *
172 ) &&
174 set_checkout_config 2 0 &&
175 test_checkout_workers 2 git -C delayed checkout -f &&
176 verify_checkout delayed &&
178 # Check that the *.d files got to the delay queue and were filtered
179 grep "smudge W.d .* \[DELAYED\]" delayed.log &&
180 grep "smudge X.d .* \[DELAYED\]" delayed.log &&
181 test_cmp delayed/W.d original &&
182 test_cmp delayed/X.d original &&
184 # Check that the parallel-eligible entries went to the right queue and
185 # were not filtered
186 ! grep "smudge Y .* \[DELAYED\]" delayed.log &&
187 ! grep "smudge Z .* \[DELAYED\]" delayed.log &&
188 test_cmp delayed/Y original &&
189 test_cmp delayed/Z original
192 test_done