]> git.ipfire.org Git - thirdparty/git.git/blob - t/t2082-parallel-checkout-attributes.sh
clone: allow "--bare" with "-o"
[thirdparty/git.git] / t / t2082-parallel-checkout-attributes.sh
1 #!/bin/sh
2
3 test_description='parallel-checkout: attributes
4
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).
10 '
11
12 TEST_NO_CREATE_REPO=1
13 . ./test-lib.sh
14 . "$TEST_DIRECTORY/lib-parallel-checkout.sh"
15 . "$TEST_DIRECTORY/lib-encoding.sh"
16
17 test_expect_success 'parallel-checkout with ident' '
18 set_checkout_config 2 0 &&
19 git init ident &&
20 (
21 cd ident &&
22 echo "A ident" >.gitattributes &&
23 echo "\$Id\$" >A &&
24 echo "\$Id\$" >B &&
25 git add -A &&
26 git commit -m id &&
27
28 rm A B &&
29 test_checkout_workers 2 git reset --hard &&
30 hexsz=$(test_oid hexsz) &&
31 grep -E "\\\$Id: [0-9a-f]{$hexsz} \\\$" A &&
32 grep "\\\$Id\\\$" B
33 )
34 '
35
36 test_expect_success 'parallel-checkout with re-encoding' '
37 set_checkout_config 2 0 &&
38 git init encoding &&
39 (
40 cd encoding &&
41 echo text >utf8-text &&
42 write_utf16 <utf8-text >utf16-text &&
43
44 echo "A working-tree-encoding=UTF-16" >.gitattributes &&
45 cp utf16-text A &&
46 cp utf8-text B &&
47 git add A B .gitattributes &&
48 git commit -m encoding &&
49
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 &&
53
54 rm A B &&
55 test_checkout_workers 2 git checkout A B &&
56
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
60 )
61 '
62
63 test_expect_success 'parallel-checkout with eol conversions' '
64 set_checkout_config 2 0 &&
65 git init eol &&
66 (
67 cd eol &&
68 printf "multi\r\nline\r\ntext" >crlf-text &&
69 printf "multi\nline\ntext" >lf-text &&
70
71 git config core.autocrlf false &&
72 echo "A eol=crlf" >.gitattributes &&
73 cp crlf-text A &&
74 cp lf-text B &&
75 git add A B .gitattributes &&
76 git commit -m eol &&
77
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 &&
81
82 rm A B &&
83 test_checkout_workers 2 git checkout A B &&
84
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
88 )
89 '
90
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.
94 #
95 test_expect_success 'parallel-checkout and external filter' '
96 set_checkout_config 2 0 &&
97 git init filter &&
98 (
99 cd filter &&
100 write_script <<-\EOF rot13.sh &&
101 tr \
102 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
103 "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
104 EOF
105
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 &&
109
110 echo abcd >original &&
111 echo nopq >rot13 &&
112
113 echo "A filter=rot13" >.gitattributes &&
114 cp original A &&
115 cp original B &&
116 cp original C &&
117 git add A B C .gitattributes &&
118 git commit -m filter &&
119
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 &&
127
128 rm A B C *.internal &&
129 test_checkout_workers 2 git checkout A B C &&
130
131 # Check that A (and only A) was smudged during checkout
132 test_cmp original A &&
133 test_cmp original B &&
134 test_cmp original C
135 )
136 '
137
138 # The delayed queue is independent from the parallel queue, and they should be
139 # able to work together in the same checkout process.
140 #
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 &&
144
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 &&
148
149 echo "abcd" >original &&
150 echo "nopq" >rot13 &&
151
152 git init delayed &&
153 (
154 cd delayed &&
155 echo "*.d filter=delay" >.gitattributes &&
156 cp ../original W.d &&
157 cp ../original X.d &&
158 cp ../original Y &&
159 cp ../original Z &&
160 git add -A &&
161 git commit -m delayed &&
162
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 &&
172
173 rm *
174 ) &&
175
176 set_checkout_config 2 0 &&
177 test_checkout_workers 2 git -C delayed checkout -f &&
178 verify_checkout delayed &&
179
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 &&
185
186 # Check that the parallel-eligible entries went to the right queue and
187 # were not filtered
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
192 '
193
194 test_done