| 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 ICONV '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 written 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 'parallel-checkout and delayed checkout' ' |
| 142 | test_config_global filter.delay.process \ |
| 143 | "test-tool rot13-filter --always-delay --log=\"$(pwd)/delayed.log\" clean smudge delay" && |
| 144 | test_config_global filter.delay.required true && |
| 145 | |
| 146 | echo "abcd" >original && |
| 147 | echo "nopq" >rot13 && |
| 148 | |
| 149 | git init delayed && |
| 150 | ( |
| 151 | cd delayed && |
| 152 | echo "*.d filter=delay" >.gitattributes && |
| 153 | cp ../original W.d && |
| 154 | cp ../original X.d && |
| 155 | cp ../original Y && |
| 156 | cp ../original Z && |
| 157 | git add -A && |
| 158 | git commit -m delayed && |
| 159 | |
| 160 | # Check that *.d files were cleaned |
| 161 | git cat-file -p :W.d >W.d.internal && |
| 162 | test_cmp W.d.internal ../rot13 && |
| 163 | git cat-file -p :X.d >X.d.internal && |
| 164 | test_cmp X.d.internal ../rot13 && |
| 165 | git cat-file -p :Y >Y.internal && |
| 166 | test_cmp Y.internal ../original && |
| 167 | git cat-file -p :Z >Z.internal && |
| 168 | test_cmp Z.internal ../original && |
| 169 | |
| 170 | rm * |
| 171 | ) && |
| 172 | |
| 173 | set_checkout_config 2 0 && |
| 174 | test_checkout_workers 2 git -C delayed checkout -f && |
| 175 | verify_checkout delayed && |
| 176 | |
| 177 | # Check that the *.d files got to the delay queue and were filtered |
| 178 | grep "smudge W.d .* \[DELAYED\]" delayed.log && |
| 179 | grep "smudge X.d .* \[DELAYED\]" delayed.log && |
| 180 | test_cmp delayed/W.d original && |
| 181 | test_cmp delayed/X.d original && |
| 182 | |
| 183 | # Check that the parallel-eligible entries went to the right queue and |
| 184 | # were not filtered |
| 185 | ! grep "smudge Y .* \[DELAYED\]" delayed.log && |
| 186 | ! grep "smudge Z .* \[DELAYED\]" delayed.log && |
| 187 | test_cmp delayed/Y original && |
| 188 | test_cmp delayed/Z original |
| 189 | ' |
| 190 | |
| 191 | test_done |