Git fork

tests: simplify construction of large blocks of text

Take advantage of here-docs to create large blocks of text rather than
using a series of `echo` statements. Not only are here-docs a natural
fit for such a task, but there is less opportunity for a broken
&&-chain.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Eric Sunshine and committed by
Junio C Hamano
020b813f 2041b0e8

+205 -202
+22 -22
t/t0021-conversion.sh
··· 118 118 # If an expanded ident ever gets into the repository, we want to make sure that 119 119 # it is collapsed before being expanded again on checkout 120 120 test_expect_success expanded_in_repo ' 121 - { 122 - echo "File with expanded keywords" 123 - echo "\$Id\$" 124 - echo "\$Id:\$" 125 - echo "\$Id: 0000000000000000000000000000000000000000 \$" 126 - echo "\$Id: NoSpaceAtEnd\$" 127 - echo "\$Id:NoSpaceAtFront \$" 128 - echo "\$Id:NoSpaceAtEitherEnd\$" 129 - echo "\$Id: NoTerminatingSymbol" 130 - echo "\$Id: Foreign Commit With Spaces \$" 131 - } >expanded-keywords.0 && 121 + cat >expanded-keywords.0 <<-\EOF && 122 + File with expanded keywords 123 + $Id$ 124 + $Id:$ 125 + $Id: 0000000000000000000000000000000000000000 $ 126 + $Id: NoSpaceAtEnd$ 127 + $Id:NoSpaceAtFront $ 128 + $Id:NoSpaceAtEitherEnd$ 129 + $Id: NoTerminatingSymbol 130 + $Id: Foreign Commit With Spaces $ 131 + EOF 132 132 133 133 { 134 134 cat expanded-keywords.0 && ··· 139 139 git commit -m "File with keywords expanded" && 140 140 id=$(git rev-parse --verify :expanded-keywords) && 141 141 142 - { 143 - echo "File with expanded keywords" 144 - echo "\$Id: $id \$" 145 - echo "\$Id: $id \$" 146 - echo "\$Id: $id \$" 147 - echo "\$Id: $id \$" 148 - echo "\$Id: $id \$" 149 - echo "\$Id: $id \$" 150 - echo "\$Id: NoTerminatingSymbol" 151 - echo "\$Id: Foreign Commit With Spaces \$" 152 - } >expected-output.0 && 142 + cat >expected-output.0 <<-EOF && 143 + File with expanded keywords 144 + \$Id: $id \$ 145 + \$Id: $id \$ 146 + \$Id: $id \$ 147 + \$Id: $id \$ 148 + \$Id: $id \$ 149 + \$Id: $id \$ 150 + \$Id: NoTerminatingSymbol 151 + \$Id: Foreign Commit With Spaces \$ 152 + EOF 153 153 { 154 154 cat expected-output.0 && 155 155 printf "\$Id: NoTerminatingSymbolAtEOF"
+4 -1
t/t4106-apply-stdin.sh
··· 18 18 ' 19 19 20 20 test_expect_success 'git apply --numstat - < patch patch' ' 21 - for i in 1 2; do echo "1 1 text"; done >expect && 21 + cat >expect <<-\EOF && 22 + 1 1 text 23 + 1 1 text 24 + EOF 22 25 git apply --numstat - < patch patch >actual && 23 26 test_cmp expect actual 24 27 '
+5 -5
t/t5510-fetch.sh
··· 40 40 git config branch.main.remote two && 41 41 git config branch.main.merge refs/heads/one && 42 42 mkdir -p .git/remotes && 43 - { 44 - echo "URL: ../two/.git/" 45 - echo "Pull: refs/heads/main:refs/heads/two" 46 - echo "Pull: refs/heads/one:refs/heads/one" 47 - } >.git/remotes/two 43 + cat >.git/remotes/two <<-\EOF 44 + URL: ../two/.git/ 45 + Pull: refs/heads/main:refs/heads/two 46 + Pull: refs/heads/one:refs/heads/one 47 + EOF 48 48 ) && 49 49 git clone . bundle && 50 50 git clone . seven
+11 -11
t/t5515-fetch-merge-logic.sh
··· 105 105 remotes="$remotes config-glob" && 106 106 107 107 mkdir -p .git/remotes && 108 - { 109 - echo "URL: ../.git/" 110 - echo "Pull: refs/heads/main:remotes/rem/main" 111 - echo "Pull: refs/heads/one:remotes/rem/one" 112 - echo "Pull: two:remotes/rem/two" 113 - echo "Pull: refs/heads/three:remotes/rem/three" 114 - } >.git/remotes/remote-explicit && 108 + cat >.git/remotes/remote-explicit <<-\EOF && 109 + URL: ../.git/ 110 + Pull: refs/heads/main:remotes/rem/main 111 + Pull: refs/heads/one:remotes/rem/one 112 + Pull: two:remotes/rem/two 113 + Pull: refs/heads/three:remotes/rem/three 114 + EOF 115 115 remotes="$remotes remote-explicit" && 116 116 117 - { 118 - echo "URL: ../.git/" 119 - echo "Pull: refs/heads/*:refs/remotes/rem/*" 120 - } >.git/remotes/remote-glob && 117 + cat >.git/remotes/remote-glob <<-\EOF && 118 + URL: ../.git/ 119 + Pull: refs/heads/*:refs/remotes/rem/* 120 + EOF 121 121 remotes="$remotes remote-glob" && 122 122 123 123 mkdir -p .git/branches &&
+4 -4
t/t6406-merge-attr.sh
··· 62 62 63 63 test_expect_success merge ' 64 64 65 - { 66 - echo "binary -merge" 67 - echo "union merge=union" 68 - } >.gitattributes && 65 + cat >.gitattributes <<-\EOF && 66 + binary -merge 67 + union merge=union 68 + EOF 69 69 70 70 if git merge main 71 71 then
+4 -4
t/t6411-merge-filemode.sh
··· 51 51 : >file2 && 52 52 git add file2 && 53 53 git commit -m b2 && 54 - { 55 - echo "100755 $H 2 file2" 56 - echo "100644 $H 3 file2" 57 - } >expect 54 + cat >expect <<-EOF 55 + 100755 $H 2 file2 56 + 100644 $H 3 file2 57 + EOF 58 58 ' 59 59 60 60 do_both_modes () {
+155 -155
t/t7810-grep.sh
··· 31 31 EOF 32 32 33 33 test_expect_success setup ' 34 - { 35 - echo foo mmap bar 36 - echo foo_mmap bar 37 - echo foo_mmap bar mmap 38 - echo foo mmap bar_mmap 39 - echo foo_mmap bar mmap baz 40 - } >file && 41 - { 42 - echo Hello world 43 - echo HeLLo world 44 - echo Hello_world 45 - echo HeLLo_world 46 - } >hello_world && 47 - { 48 - echo "a+b*c" 49 - echo "a+bc" 50 - echo "abc" 51 - } >ab && 52 - { 53 - echo d && 54 - echo 0 55 - } >d0 && 34 + cat >file <<-\EOF && 35 + foo mmap bar 36 + foo_mmap bar 37 + foo_mmap bar mmap 38 + foo mmap bar_mmap 39 + foo_mmap bar mmap baz 40 + EOF 41 + cat >hello_world <<-\EOF && 42 + Hello world 43 + HeLLo world 44 + Hello_world 45 + HeLLo_world 46 + EOF 47 + cat >ab <<-\EOF && 48 + a+b*c 49 + a+bc 50 + abc 51 + EOF 52 + cat >d0 <<-\EOF && 53 + d 54 + 0 55 + EOF 56 56 echo vvv >v && 57 57 echo ww w >w && 58 58 echo x x xx x >x && ··· 63 63 echo vvv >t/v && 64 64 mkdir t/a && 65 65 echo vvv >t/a/v && 66 - { 67 - echo "line without leading space1" 68 - echo " line with leading space1" 69 - echo " line with leading space2" 70 - echo " line with leading space3" 71 - echo "line without leading space2" 72 - } >space && 66 + qz_to_tab_space >space <<-\EOF && 67 + line without leading space1 68 + Zline with leading space1 69 + Zline with leading space2 70 + Zline with leading space3 71 + line without leading space2 72 + EOF 73 73 cat >hello.ps1 <<-\EOF && 74 74 # No-op. 75 75 function dummy() {} ··· 106 106 esac 107 107 108 108 test_expect_success "grep -w $L" ' 109 - { 110 - echo ${HC}file:1:foo mmap bar 111 - echo ${HC}file:3:foo_mmap bar mmap 112 - echo ${HC}file:4:foo mmap bar_mmap 113 - echo ${HC}file:5:foo_mmap bar mmap baz 114 - } >expected && 109 + cat >expected <<-EOF && 110 + ${HC}file:1:foo mmap bar 111 + ${HC}file:3:foo_mmap bar mmap 112 + ${HC}file:4:foo mmap bar_mmap 113 + ${HC}file:5:foo_mmap bar mmap baz 114 + EOF 115 115 git -c grep.linenumber=false grep -n -w -e mmap $H >actual && 116 116 test_cmp expected actual 117 117 ' 118 118 119 119 test_expect_success "grep -w $L (with --column)" ' 120 - { 121 - echo ${HC}file:5:foo mmap bar 122 - echo ${HC}file:14:foo_mmap bar mmap 123 - echo ${HC}file:5:foo mmap bar_mmap 124 - echo ${HC}file:14:foo_mmap bar mmap baz 125 - } >expected && 120 + cat >expected <<-EOF && 121 + ${HC}file:5:foo mmap bar 122 + ${HC}file:14:foo_mmap bar mmap 123 + ${HC}file:5:foo mmap bar_mmap 124 + ${HC}file:14:foo_mmap bar mmap baz 125 + EOF 126 126 git grep --column -w -e mmap $H >actual && 127 127 test_cmp expected actual 128 128 ' 129 129 130 130 test_expect_success "grep -w $L (with --column, extended OR)" ' 131 - { 132 - echo ${HC}file:14:foo_mmap bar mmap 133 - echo ${HC}file:19:foo_mmap bar mmap baz 134 - } >expected && 131 + cat >expected <<-EOF && 132 + ${HC}file:14:foo_mmap bar mmap 133 + ${HC}file:19:foo_mmap bar mmap baz 134 + EOF 135 135 git grep --column -w -e mmap$ --or -e baz $H >actual && 136 136 test_cmp expected actual 137 137 ' 138 138 139 139 test_expect_success "grep -w $L (with --column, --invert-match)" ' 140 - { 141 - echo ${HC}file:1:foo mmap bar 142 - echo ${HC}file:1:foo_mmap bar 143 - echo ${HC}file:1:foo_mmap bar mmap 144 - echo ${HC}file:1:foo mmap bar_mmap 145 - } >expected && 140 + cat >expected <<-EOF && 141 + ${HC}file:1:foo mmap bar 142 + ${HC}file:1:foo_mmap bar 143 + ${HC}file:1:foo_mmap bar mmap 144 + ${HC}file:1:foo mmap bar_mmap 145 + EOF 146 146 git grep --column --invert-match -w -e baz $H -- file >actual && 147 147 test_cmp expected actual 148 148 ' 149 149 150 150 test_expect_success "grep $L (with --column, --invert-match, extended OR)" ' 151 - { 152 - echo ${HC}hello_world:6:HeLLo_world 153 - } >expected && 151 + cat >expected <<-EOF && 152 + ${HC}hello_world:6:HeLLo_world 153 + EOF 154 154 git grep --column --invert-match -e ll --or --not -e _ $H -- hello_world \ 155 155 >actual && 156 156 test_cmp expected actual 157 157 ' 158 158 159 159 test_expect_success "grep $L (with --column, --invert-match, extended AND)" ' 160 - { 161 - echo ${HC}hello_world:3:Hello world 162 - echo ${HC}hello_world:3:Hello_world 163 - echo ${HC}hello_world:6:HeLLo_world 164 - } >expected && 160 + cat >expected <<-EOF && 161 + ${HC}hello_world:3:Hello world 162 + ${HC}hello_world:3:Hello_world 163 + ${HC}hello_world:6:HeLLo_world 164 + EOF 165 165 git grep --column --invert-match --not -e _ --and --not -e ll $H -- hello_world \ 166 166 >actual && 167 167 test_cmp expected actual 168 168 ' 169 169 170 170 test_expect_success "grep $L (with --column, double-negation)" ' 171 - { 172 - echo ${HC}file:1:foo_mmap bar mmap baz 173 - } >expected && 171 + cat >expected <<-EOF && 172 + ${HC}file:1:foo_mmap bar mmap baz 173 + EOF 174 174 git grep --column --not \( --not -e foo --or --not -e baz \) $H -- file \ 175 175 >actual && 176 176 test_cmp expected actual 177 177 ' 178 178 179 179 test_expect_success "grep -w $L (with --column, -C)" ' 180 - { 181 - echo ${HC}file:5:foo mmap bar 182 - echo ${HC}file-foo_mmap bar 183 - echo ${HC}file:14:foo_mmap bar mmap 184 - echo ${HC}file:5:foo mmap bar_mmap 185 - echo ${HC}file:14:foo_mmap bar mmap baz 186 - } >expected && 180 + cat >expected <<-EOF && 181 + ${HC}file:5:foo mmap bar 182 + ${HC}file-foo_mmap bar 183 + ${HC}file:14:foo_mmap bar mmap 184 + ${HC}file:5:foo mmap bar_mmap 185 + ${HC}file:14:foo_mmap bar mmap baz 186 + EOF 187 187 git grep --column -w -C1 -e mmap $H >actual && 188 188 test_cmp expected actual 189 189 ' 190 190 191 191 test_expect_success "grep -w $L (with --line-number, --column)" ' 192 - { 193 - echo ${HC}file:1:5:foo mmap bar 194 - echo ${HC}file:3:14:foo_mmap bar mmap 195 - echo ${HC}file:4:5:foo mmap bar_mmap 196 - echo ${HC}file:5:14:foo_mmap bar mmap baz 197 - } >expected && 192 + cat >expected <<-EOF && 193 + ${HC}file:1:5:foo mmap bar 194 + ${HC}file:3:14:foo_mmap bar mmap 195 + ${HC}file:4:5:foo mmap bar_mmap 196 + ${HC}file:5:14:foo_mmap bar mmap baz 197 + EOF 198 198 git grep -n --column -w -e mmap $H >actual && 199 199 test_cmp expected actual 200 200 ' 201 201 202 202 test_expect_success "grep -w $L (with non-extended patterns, --column)" ' 203 - { 204 - echo ${HC}file:5:foo mmap bar 205 - echo ${HC}file:10:foo_mmap bar 206 - echo ${HC}file:10:foo_mmap bar mmap 207 - echo ${HC}file:5:foo mmap bar_mmap 208 - echo ${HC}file:10:foo_mmap bar mmap baz 209 - } >expected && 203 + cat >expected <<-EOF && 204 + ${HC}file:5:foo mmap bar 205 + ${HC}file:10:foo_mmap bar 206 + ${HC}file:10:foo_mmap bar mmap 207 + ${HC}file:5:foo mmap bar_mmap 208 + ${HC}file:10:foo_mmap bar mmap baz 209 + EOF 210 210 git grep --column -w -e bar -e mmap $H >actual && 211 211 test_cmp expected actual 212 212 ' 213 213 214 214 test_expect_success "grep -w $L" ' 215 - { 216 - echo ${HC}file:1:foo mmap bar 217 - echo ${HC}file:3:foo_mmap bar mmap 218 - echo ${HC}file:4:foo mmap bar_mmap 219 - echo ${HC}file:5:foo_mmap bar mmap baz 220 - } >expected && 215 + cat >expected <<-EOF && 216 + ${HC}file:1:foo mmap bar 217 + ${HC}file:3:foo_mmap bar mmap 218 + ${HC}file:4:foo mmap bar_mmap 219 + ${HC}file:5:foo_mmap bar mmap baz 220 + EOF 221 221 git -c grep.linenumber=true grep -w -e mmap $H >actual && 222 222 test_cmp expected actual 223 223 ' 224 224 225 225 test_expect_success "grep -w $L" ' 226 - { 227 - echo ${HC}file:foo mmap bar 228 - echo ${HC}file:foo_mmap bar mmap 229 - echo ${HC}file:foo mmap bar_mmap 230 - echo ${HC}file:foo_mmap bar mmap baz 231 - } >expected && 226 + cat >expected <<-EOF && 227 + ${HC}file:foo mmap bar 228 + ${HC}file:foo_mmap bar mmap 229 + ${HC}file:foo mmap bar_mmap 230 + ${HC}file:foo_mmap bar mmap baz 231 + EOF 232 232 git -c grep.linenumber=true grep --no-line-number -w -e mmap $H >actual && 233 233 test_cmp expected actual 234 234 ' ··· 239 239 ' 240 240 241 241 test_expect_success "grep -w $L (x)" ' 242 - { 243 - echo ${HC}x:1:x x xx x 244 - } >expected && 242 + cat >expected <<-EOF && 243 + ${HC}x:1:x x xx x 244 + EOF 245 245 git grep -n -w -e "x xx* x" $H >actual && 246 246 test_cmp expected actual 247 247 ' 248 248 249 249 test_expect_success "grep -w $L (y-1)" ' 250 - { 251 - echo ${HC}y:1:y yy 252 - } >expected && 250 + cat >expected <<-EOF && 251 + ${HC}y:1:y yy 252 + EOF 253 253 git grep -n -w -e "^y" $H >actual && 254 254 test_cmp expected actual 255 255 ' ··· 277 277 ' 278 278 279 279 test_expect_success "grep $L (with --column, --only-matching)" ' 280 - { 281 - echo ${HC}file:1:5:mmap 282 - echo ${HC}file:2:5:mmap 283 - echo ${HC}file:3:5:mmap 284 - echo ${HC}file:3:13:mmap 285 - echo ${HC}file:4:5:mmap 286 - echo ${HC}file:4:13:mmap 287 - echo ${HC}file:5:5:mmap 288 - echo ${HC}file:5:13:mmap 289 - } >expected && 280 + cat >expected <<-EOF && 281 + ${HC}file:1:5:mmap 282 + ${HC}file:2:5:mmap 283 + ${HC}file:3:5:mmap 284 + ${HC}file:3:13:mmap 285 + ${HC}file:4:5:mmap 286 + ${HC}file:4:13:mmap 287 + ${HC}file:5:5:mmap 288 + ${HC}file:5:13:mmap 289 + EOF 290 290 git grep --column -n -o -e mmap $H >actual && 291 291 test_cmp expected actual 292 292 ' ··· 320 320 ' 321 321 322 322 test_expect_success "grep --max-depth -1 $L" ' 323 - { 324 - echo ${HC}t/a/v:1:vvv 325 - echo ${HC}t/v:1:vvv 326 - echo ${HC}v:1:vvv 327 - } >expected && 323 + cat >expected <<-EOF && 324 + ${HC}t/a/v:1:vvv 325 + ${HC}t/v:1:vvv 326 + ${HC}v:1:vvv 327 + EOF 328 328 git grep --max-depth -1 -n -e vvv $H >actual && 329 329 test_cmp expected actual && 330 330 git grep --recursive -n -e vvv $H >actual && ··· 332 332 ' 333 333 334 334 test_expect_success "grep --max-depth 0 $L" ' 335 - { 336 - echo ${HC}v:1:vvv 337 - } >expected && 335 + cat >expected <<-EOF && 336 + ${HC}v:1:vvv 337 + EOF 338 338 git grep --max-depth 0 -n -e vvv $H >actual && 339 339 test_cmp expected actual && 340 340 git grep --no-recursive -n -e vvv $H >actual && ··· 342 342 ' 343 343 344 344 test_expect_success "grep --max-depth 0 -- '*' $L" ' 345 - { 346 - echo ${HC}t/a/v:1:vvv 347 - echo ${HC}t/v:1:vvv 348 - echo ${HC}v:1:vvv 349 - } >expected && 345 + cat >expected <<-EOF && 346 + ${HC}t/a/v:1:vvv 347 + ${HC}t/v:1:vvv 348 + ${HC}v:1:vvv 349 + EOF 350 350 git grep --max-depth 0 -n -e vvv $H -- "*" >actual && 351 351 test_cmp expected actual && 352 352 git grep --no-recursive -n -e vvv $H -- "*" >actual && ··· 354 354 ' 355 355 356 356 test_expect_success "grep --max-depth 1 $L" ' 357 - { 358 - echo ${HC}t/v:1:vvv 359 - echo ${HC}v:1:vvv 360 - } >expected && 357 + cat >expected <<-EOF && 358 + ${HC}t/v:1:vvv 359 + ${HC}v:1:vvv 360 + EOF 361 361 git grep --max-depth 1 -n -e vvv $H >actual && 362 362 test_cmp expected actual 363 363 ' 364 364 365 365 test_expect_success "grep --max-depth 0 -- t $L" ' 366 - { 367 - echo ${HC}t/v:1:vvv 368 - } >expected && 366 + cat >expected <<-EOF && 367 + ${HC}t/v:1:vvv 368 + EOF 369 369 git grep --max-depth 0 -n -e vvv $H -- t >actual && 370 370 test_cmp expected actual && 371 371 git grep --no-recursive -n -e vvv $H -- t >actual && ··· 373 373 ' 374 374 375 375 test_expect_success "grep --max-depth 0 -- . t $L" ' 376 - { 377 - echo ${HC}t/v:1:vvv 378 - echo ${HC}v:1:vvv 379 - } >expected && 376 + cat >expected <<-EOF && 377 + ${HC}t/v:1:vvv 378 + ${HC}v:1:vvv 379 + EOF 380 380 git grep --max-depth 0 -n -e vvv $H -- . t >actual && 381 381 test_cmp expected actual && 382 382 git grep --no-recursive -n -e vvv $H -- . t >actual && ··· 384 384 ' 385 385 386 386 test_expect_success "grep --max-depth 0 -- t . $L" ' 387 - { 388 - echo ${HC}t/v:1:vvv 389 - echo ${HC}v:1:vvv 390 - } >expected && 387 + cat >expected <<-EOF && 388 + ${HC}t/v:1:vvv 389 + ${HC}v:1:vvv 390 + EOF 391 391 git grep --max-depth 0 -n -e vvv $H -- t . >actual && 392 392 test_cmp expected actual && 393 393 git grep --no-recursive -n -e vvv $H -- t . >actual && ··· 1314 1314 ' 1315 1315 1316 1316 test_expect_success PCRE 'grep -P -v pattern' ' 1317 - { 1318 - echo "ab:a+b*c" 1319 - echo "ab:a+bc" 1320 - } >expected && 1317 + cat >expected <<-\EOF && 1318 + ab:a+b*c 1319 + ab:a+bc 1320 + EOF 1321 1321 git grep -P -v "abc" ab >actual && 1322 1322 test_cmp expected actual 1323 1323 ' ··· 1331 1331 ' 1332 1332 1333 1333 test_expect_success PCRE 'grep -P -w pattern' ' 1334 - { 1335 - echo "hello_world:Hello world" 1336 - echo "hello_world:HeLLo world" 1337 - } >expected && 1334 + cat >expected <<-\EOF && 1335 + hello_world:Hello world 1336 + hello_world:HeLLo world 1337 + EOF 1338 1338 git grep -P -w "He((?i)ll)o" hello_world >actual && 1339 1339 test_cmp expected actual 1340 1340 ' ··· 1469 1469 ' 1470 1470 1471 1471 test_expect_success 'grep -G pattern with grep.patternType=fixed' ' 1472 - { 1473 - echo "ab:a+b*c" 1474 - echo "ab:a+bc" 1475 - } >expected && 1472 + cat >expected <<-\EOF && 1473 + ab:a+b*c 1474 + ab:a+bc 1475 + EOF 1476 1476 git \ 1477 1477 -c grep.patterntype=fixed \ 1478 1478 grep -G "a+b" ab >actual && ··· 1480 1480 ' 1481 1481 1482 1482 test_expect_success 'grep -E pattern with grep.patternType=fixed' ' 1483 - { 1484 - echo "ab:a+b*c" 1485 - echo "ab:a+bc" 1486 - echo "ab:abc" 1487 - } >expected && 1483 + cat >expected <<-\EOF && 1484 + ab:a+b*c 1485 + ab:a+bc 1486 + ab:abc 1487 + EOF 1488 1488 git \ 1489 1489 -c grep.patterntype=fixed \ 1490 1490 grep -E "a+" ab >actual &&