|
| 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 | + git init ident && |
| 19 | + ( |
| 20 | + cd ident && |
| 21 | + echo "A ident" >.gitattributes && |
| 22 | + echo "\$Id\$" >A && |
| 23 | + echo "\$Id\$" >B && |
| 24 | + git add -A && |
| 25 | + git commit -m id && |
| 26 | +
|
| 27 | + rm A B && |
| 28 | + git_pc 2 0 2 reset --hard && |
| 29 | + hexsz=$(test_oid hexsz) && |
| 30 | + grep -E "\\\$Id: [0-9a-f]{$hexsz} \\\$" A && |
| 31 | + grep "\\\$Id\\\$" B |
| 32 | + ) |
| 33 | +' |
| 34 | + |
| 35 | +test_expect_success 'parallel-checkout with re-encoding' ' |
| 36 | + git init encoding && |
| 37 | + ( |
| 38 | + cd encoding && |
| 39 | + echo text >utf8-text && |
| 40 | + cat utf8-text | write_utf16 >utf16-text && |
| 41 | +
|
| 42 | + echo "A working-tree-encoding=UTF-16" >.gitattributes && |
| 43 | + cp utf16-text A && |
| 44 | + cp utf16-text B && |
| 45 | + git add A B .gitattributes && |
| 46 | + git commit -m encoding && |
| 47 | +
|
| 48 | + # Check that A (and only A) is stored in UTF-8 |
| 49 | + git cat-file -p :A >A.internal && |
| 50 | + test_cmp_bin utf8-text A.internal && |
| 51 | + git cat-file -p :B >B.internal && |
| 52 | + test_cmp_bin utf16-text B.internal && |
| 53 | +
|
| 54 | + # Check that A is re-encoded during checkout |
| 55 | + rm A B && |
| 56 | + git_pc 2 0 2 checkout A B && |
| 57 | + test_cmp_bin utf16-text A |
| 58 | + ) |
| 59 | +' |
| 60 | + |
| 61 | +test_expect_success 'parallel-checkout with eol conversions' ' |
| 62 | + git init eol && |
| 63 | + ( |
| 64 | + cd eol && |
| 65 | + git config core.autocrlf false && |
| 66 | + printf "multi\r\nline\r\ntext" >crlf-text && |
| 67 | + printf "multi\nline\ntext" >lf-text && |
| 68 | +
|
| 69 | + echo "A text eol=crlf" >.gitattributes && |
| 70 | + echo "B -text" >>.gitattributes && |
| 71 | + cp crlf-text A && |
| 72 | + cp crlf-text B && |
| 73 | + git add A B .gitattributes && |
| 74 | + git commit -m eol && |
| 75 | +
|
| 76 | + # Check that A (and only A) is stored with LF format |
| 77 | + git cat-file -p :A >A.internal && |
| 78 | + test_cmp_bin lf-text A.internal && |
| 79 | + git cat-file -p :B >B.internal && |
| 80 | + test_cmp_bin crlf-text B.internal && |
| 81 | +
|
| 82 | + # Check that A is converted to CRLF during checkout |
| 83 | + rm A B && |
| 84 | + git_pc 2 0 2 checkout A B && |
| 85 | + test_cmp_bin crlf-text A |
| 86 | + ) |
| 87 | +' |
| 88 | + |
| 89 | +test_cmp_str() |
| 90 | +{ |
| 91 | + echo "$1" >tmp && |
| 92 | + test_cmp tmp "$2" |
| 93 | +} |
| 94 | + |
| 95 | +# Entries that require an external filter are not eligible for parallel |
| 96 | +# checkout. Check that both the parallel-eligible and non-eligible entries are |
| 97 | +# properly writen in a single checkout process. |
| 98 | +# |
| 99 | +test_expect_success 'parallel-checkout and external filter' ' |
| 100 | + git init filter && |
| 101 | + ( |
| 102 | + cd filter && |
| 103 | + git config filter.x2y.clean "tr x y" && |
| 104 | + git config filter.x2y.smudge "tr y x" && |
| 105 | + git config filter.x2y.required true && |
| 106 | +
|
| 107 | + echo "A filter=x2y" >.gitattributes && |
| 108 | + echo x >A && |
| 109 | + echo x >B && |
| 110 | + echo x >C && |
| 111 | + git add -A && |
| 112 | + git commit -m filter && |
| 113 | +
|
| 114 | + # Check that A (and only A) was cleaned |
| 115 | + git cat-file -p :A >A.internal && |
| 116 | + test_cmp_str y A.internal && |
| 117 | + git cat-file -p :B >B.internal && |
| 118 | + test_cmp_str x B.internal && |
| 119 | + git cat-file -p :C >C.internal && |
| 120 | + test_cmp_str x C.internal && |
| 121 | +
|
| 122 | + rm A B C *.internal && |
| 123 | + git_pc 2 0 2 checkout A B C && |
| 124 | + test_cmp_str x A && |
| 125 | + test_cmp_str x B && |
| 126 | + test_cmp_str x C |
| 127 | + ) |
| 128 | +' |
| 129 | + |
| 130 | +# The delayed queue is independent from the parallel queue, and they should be |
| 131 | +# able to work together in the same checkout process. |
| 132 | +# |
| 133 | +test_expect_success PERL 'parallel-checkout and delayed checkout' ' |
| 134 | + write_script rot13-filter.pl "$PERL_PATH" \ |
| 135 | + <"$TEST_DIRECTORY"/t0021/rot13-filter.pl && |
| 136 | + test_config_global filter.delay.process \ |
| 137 | + "\"$(pwd)/rot13-filter.pl\" \"$(pwd)/delayed.log\" clean smudge delay" && |
| 138 | + test_config_global filter.delay.required true && |
| 139 | +
|
| 140 | + echo "a b c" >delay-content && |
| 141 | + echo "n o p" >delay-rot13-content && |
| 142 | +
|
| 143 | + git init delayed && |
| 144 | + ( |
| 145 | + cd delayed && |
| 146 | + echo "*.a filter=delay" >.gitattributes && |
| 147 | + cp ../delay-content test-delay10.a && |
| 148 | + cp ../delay-content test-delay11.a && |
| 149 | + echo parallel >parallel1.b && |
| 150 | + echo parallel >parallel2.b && |
| 151 | + git add -A && |
| 152 | + git commit -m delayed && |
| 153 | +
|
| 154 | + # Check that the stored data was cleaned |
| 155 | + git cat-file -p :test-delay10.a > delay10.internal && |
| 156 | + test_cmp delay10.internal ../delay-rot13-content && |
| 157 | + git cat-file -p :test-delay11.a > delay11.internal && |
| 158 | + test_cmp delay11.internal ../delay-rot13-content && |
| 159 | + rm *.internal && |
| 160 | +
|
| 161 | + rm *.a *.b |
| 162 | + ) && |
| 163 | +
|
| 164 | + git_pc 2 0 2 -C delayed checkout -f && |
| 165 | + verify_checkout delayed && |
| 166 | +
|
| 167 | + # Check that the *.a files got to the delay queue and were filtered |
| 168 | + grep "smudge test-delay10.a .* \[DELAYED\]" delayed.log && |
| 169 | + grep "smudge test-delay11.a .* \[DELAYED\]" delayed.log && |
| 170 | + test_cmp delayed/test-delay10.a delay-content && |
| 171 | + test_cmp delayed/test-delay11.a delay-content |
| 172 | +' |
| 173 | + |
| 174 | +test_done |
0 commit comments