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).
14 .
"$TEST_DIRECTORY/lib-parallel-checkout.sh"
15 .
"$TEST_DIRECTORY/lib-encoding.sh"
17 test_expect_success
'parallel-checkout with ident' '
18 set_checkout_config 2 0 &&
22 echo "A ident" >.gitattributes &&
29 test_checkout_workers 2 git reset --hard &&
30 hexsz=$(test_oid hexsz) &&
31 grep -E "\\\$Id: [0-9a-f]{$hexsz} \\\$" A &&
36 test_expect_success
'parallel-checkout with re-encoding' '
37 set_checkout_config 2 0 &&
41 echo text >utf8-text &&
42 write_utf16 <utf8-text >utf16-text &&
44 echo "A working-tree-encoding=UTF-16" >.gitattributes &&
47 git add A B .gitattributes &&
48 git commit -m encoding &&
50 # Check that A is stored in UTF-8
51 git cat-file -p :A >A.internal &&
52 test_cmp_bin utf8-text A.internal &&
55 test_checkout_workers 2 git checkout A B &&
57 # Check that A (and only A) is re-encoded during checkout
58 test_cmp_bin utf16-text A &&
59 test_cmp_bin utf8-text B
63 test_expect_success
'parallel-checkout with eol conversions' '
64 set_checkout_config 2 0 &&
68 printf "multi\r\nline\r\ntext" >crlf-text &&
69 printf "multi\nline\ntext" >lf-text &&
71 git config core.autocrlf false &&
72 echo "A eol=crlf" >.gitattributes &&
75 git add A B .gitattributes &&
78 # Check that A is stored with LF format
79 git cat-file -p :A >A.internal &&
80 test_cmp_bin lf-text A.internal &&
83 test_checkout_workers 2 git checkout A B &&
85 # Check that A (and only A) is converted to CRLF during checkout
86 test_cmp_bin crlf-text A &&
87 test_cmp_bin lf-text B
91 # Entries that require an external filter are not eligible for parallel
92 # checkout. Check that both the parallel-eligible and non-eligible entries are
93 # properly writen in a single checkout operation.
95 test_expect_success
'parallel-checkout and external filter' '
96 set_checkout_config 2 0 &&
100 write_script <<-\EOF rot13.sh &&
102 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
103 "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
106 git config filter.rot13.clean "\"$(pwd)/rot13.sh\"" &&
107 git config filter.rot13.smudge "\"$(pwd)/rot13.sh\"" &&
108 git config filter.rot13.required true &&
110 echo abcd >original &&
113 echo "A filter=rot13" >.gitattributes &&
117 git add A B C .gitattributes &&
118 git commit -m filter &&
120 # Check that A (and only A) was cleaned
121 git cat-file -p :A >A.internal &&
122 test_cmp rot13 A.internal &&
123 git cat-file -p :B >B.internal &&
124 test_cmp original B.internal &&
125 git cat-file -p :C >C.internal &&
126 test_cmp original C.internal &&
128 rm A B C *.internal &&
129 test_checkout_workers 2 git checkout A B C &&
131 # Check that A (and only A) was smudged during checkout
132 test_cmp original A &&
133 test_cmp original B &&
138 # The delayed queue is independent from the parallel queue, and they should be
139 # able to work together in the same checkout process.
141 test_expect_success PERL
'parallel-checkout and delayed checkout' '
142 write_script rot13-filter.pl "$PERL_PATH" \
143 <"$TEST_DIRECTORY"/t0021/rot13-filter.pl &&
145 test_config_global filter.delay.process \
146 "\"$(pwd)/rot13-filter.pl\" --always-delay \"$(pwd)/delayed.log\" clean smudge delay" &&
147 test_config_global filter.delay.required true &&
149 echo "abcd" >original &&
150 echo "nopq" >rot13 &&
155 echo "*.d filter=delay" >.gitattributes &&
156 cp ../original W.d &&
157 cp ../original X.d &&
161 git commit -m delayed &&
163 # Check that *.d files were cleaned
164 git cat-file -p :W.d >W.d.internal &&
165 test_cmp W.d.internal ../rot13 &&
166 git cat-file -p :X.d >X.d.internal &&
167 test_cmp X.d.internal ../rot13 &&
168 git cat-file -p :Y >Y.internal &&
169 test_cmp Y.internal ../original &&
170 git cat-file -p :Z >Z.internal &&
171 test_cmp Z.internal ../original &&
176 set_checkout_config 2 0 &&
177 test_checkout_workers 2 git -C delayed checkout -f &&
178 verify_checkout delayed &&
180 # Check that the *.d files got to the delay queue and were filtered
181 grep "smudge W.d .* \[DELAYED\]" delayed.log &&
182 grep "smudge X.d .* \[DELAYED\]" delayed.log &&
183 test_cmp delayed/W.d original &&
184 test_cmp delayed/X.d original &&
186 # Check that the parallel-eligible entries went to the right queue and
188 ! grep "smudge Y .* \[DELAYED\]" delayed.log &&
189 ! grep "smudge Z .* \[DELAYED\]" delayed.log &&
190 test_cmp delayed/Y original &&
191 test_cmp delayed/Z original