Changeset 782 for git/branches/dmik/t/t1300-repo-config.sh
- Timestamp:
- Jun 23, 2014, 9:45:51 PM (11 years ago)
- Location:
- git/branches/dmik
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
git/branches/dmik ¶
- Property svn:mergeinfo changed
/git/vendor/2.0.0 (added) merged: 777 /git/vendor/current merged: 772,774,776
- Property svn:mergeinfo changed
-
TabularUnified git/branches/dmik/t/t1300-repo-config.sh ¶
r626 r782 56 56 ' 57 57 58 test_expect_success 'replace with non-match' \ 59 'git config core.penguin kingpin !blue' 60 61 test_expect_success 'replace with non-match (actually matching)' \ 62 'git config core.penguin "very blue" !kingpin' 58 test_expect_success 'replace with non-match' ' 59 git config core.penguin kingpin !blue 60 ' 61 62 test_expect_success 'replace with non-match (actually matching)' ' 63 git config core.penguin "very blue" !kingpin 64 ' 63 65 64 66 cat > expect << EOF … … 109 111 EOF 110 112 111 test_expect_success 'unset with cont. lines' \ 112 'git config --unset beta.baz' 113 test_expect_success 'unset with cont. lines' ' 114 git config --unset beta.baz 115 ' 113 116 114 117 cat > expect <<\EOF … … 134 137 cp .git/config .git/config2 135 138 136 test_expect_success 'multiple unset' \ 137 'git config --unset-all beta.haha' 139 test_expect_success 'multiple unset' ' 140 git config --unset-all beta.haha 141 ' 138 142 139 143 cat > expect << EOF … … 146 150 EOF 147 151 148 test_expect_success 'multiple unset is correct' 'test_cmp expect .git/config' 152 test_expect_success 'multiple unset is correct' ' 153 test_cmp expect .git/config 154 ' 149 155 150 156 cp .git/config2 .git/config … … 157 163 rm .git/config2 158 164 159 test_expect_success '--replace-all' \ 160 'git config --replace-all beta.haha gamma' 165 test_expect_success '--replace-all' ' 166 git config --replace-all beta.haha gamma 167 ' 161 168 162 169 cat > expect << EOF … … 170 177 EOF 171 178 172 test_expect_success 'all replaced' 'test_cmp expect .git/config' 179 test_expect_success 'all replaced' ' 180 test_cmp expect .git/config 181 ' 173 182 174 183 cat > expect << EOF … … 201 210 ' 202 211 203 test_expect_success 'get value' 'test alpha = $(git config beta.haha)' 212 test_expect_success 'get value' ' 213 echo alpha >expect && 214 git config beta.haha >actual && 215 test_cmp expect actual 216 ' 204 217 205 218 cat > expect << EOF … … 232 245 ' 233 246 234 test_expect_success 'non-match' \ 235 'git config --get nextsection.nonewline !for' 236 237 test_expect_success 'non-match value' \ 238 'test wow = $(git config --get nextsection.nonewline !for)' 239 240 test_expect_success 'ambiguous get' ' 241 test_must_fail git config --get nextsection.nonewline 242 ' 243 244 test_expect_success 'get multivar' \ 245 'git config --get-all nextsection.nonewline' 247 test_expect_success 'non-match' ' 248 git config --get nextsection.nonewline !for 249 ' 250 251 test_expect_success 'non-match value' ' 252 echo wow >expect && 253 git config --get nextsection.nonewline !for >actual && 254 test_cmp expect actual 255 ' 256 257 test_expect_success 'multi-valued get returns final one' ' 258 echo "wow2 for me" >expect && 259 git config --get nextsection.nonewline >actual && 260 test_cmp expect actual 261 ' 262 263 test_expect_success 'multi-valued get-all returns all' ' 264 cat >expect <<-\EOF && 265 wow 266 wow2 for me 267 EOF 268 git config --get-all nextsection.nonewline >actual && 269 test_cmp expect actual 270 ' 246 271 247 272 cat > expect << EOF … … 260 285 ' 261 286 262 test_expect_success 'ambiguous value' '263 test_must_fail git config nextsection.nonewline264 '265 266 287 test_expect_success 'ambiguous unset' ' 267 288 test_must_fail git config --unset nextsection.nonewline … … 291 312 test_expect_success 'correct key' 'git config 123456.a123 987' 292 313 293 test_expect_success 'hierarchical section' \ 294 'git config Version.1.2.3eX.Alpha beta' 314 test_expect_success 'hierarchical section' ' 315 git config Version.1.2.3eX.Alpha beta 316 ' 295 317 296 318 cat > expect << EOF … … 308 330 EOF 309 331 310 test_expect_success 'hierarchical section value' 'test_cmp expect .git/config' 332 test_expect_success 'hierarchical section value' ' 333 test_cmp expect .git/config 334 ' 311 335 312 336 cat > expect << EOF … … 317 341 EOF 318 342 319 test_expect_success 'working --list' \ 320 'git config --list > output && cmp output expect' 321 343 test_expect_success 'working --list' ' 344 git config --list > output && 345 test_cmp expect output 346 ' 322 347 cat > expect << EOF 323 348 EOF … … 333 358 EOF 334 359 335 test_expect_success '--get-regexp' \ 336 'git config --get-regexp in > output && cmp output expect' 360 test_expect_success '--get-regexp' ' 361 git config --get-regexp in >output && 362 test_cmp expect output 363 ' 337 364 338 365 cat > expect << EOF … … 354 381 EOF 355 382 356 test_expect_success 'get variable with no value' \ 357 'git config --get novalue.variable ^$' 358 359 test_expect_success 'get variable with empty value' \ 360 'git config --get emptyvalue.variable ^$' 383 test_expect_success 'get variable with no value' ' 384 git config --get novalue.variable ^$ 385 ' 386 387 test_expect_success 'get variable with empty value' ' 388 git config --get emptyvalue.variable ^$ 389 ' 361 390 362 391 echo novalue.variable > expect 363 392 364 test_expect_success 'get-regexp variable with no value' \ 365 'git config --get-regexp novalue > output && 366 cmp output expect' 393 test_expect_success 'get-regexp variable with no value' ' 394 git config --get-regexp novalue > output && 395 test_cmp expect output 396 ' 367 397 368 398 echo 'novalue.variable true' > expect 369 399 370 test_expect_success 'get-regexp --bool variable with no value' \ 371 'git config --bool --get-regexp novalue > output && 372 cmp output expect' 400 test_expect_success 'get-regexp --bool variable with no value' ' 401 git config --bool --get-regexp novalue > output && 402 test_cmp expect output 403 ' 373 404 374 405 echo 'emptyvalue.variable ' > expect 375 406 376 test_expect_success 'get-regexp variable with empty value' \ 377 'git config --get-regexp emptyvalue > output && 378 cmp output expect' 407 test_expect_success 'get-regexp variable with empty value' ' 408 git config --get-regexp emptyvalue > output && 409 test_cmp expect output 410 ' 379 411 380 412 echo true > expect 381 413 382 test_expect_success 'get bool variable with no value' \ 383 'git config --bool novalue.variable > output && 384 cmp output expect' 414 test_expect_success 'get bool variable with no value' ' 415 git config --bool novalue.variable > output && 416 test_cmp expect output 417 ' 385 418 386 419 echo false > expect 387 420 388 test_expect_success 'get bool variable with empty value' \ 389 'git config --bool emptyvalue.variable > output && 390 cmp output expect' 421 test_expect_success 'get bool variable with empty value' ' 422 git config --bool emptyvalue.variable > output && 423 test_cmp expect output 424 ' 391 425 392 426 test_expect_success 'no arguments, but no crash' ' 393 427 test_must_fail git config >output 2>&1 && 394 grep usage output428 test_i18ngrep usage output 395 429 ' 396 430 … … 428 462 ' 429 463 430 test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' \ 431 'test_must_fail git config --file non-existing-config -l' 464 test_expect_success 'alternative --file (non-existing file should fail)' ' 465 test_must_fail git config --file non-existing-config -l 466 ' 432 467 433 468 cat > other-config << EOF … … 441 476 442 477 test_expect_success 'alternative GIT_CONFIG' ' 443 GIT_CONFIG=other-config git config - l>output &&478 GIT_CONFIG=other-config git config --list >output && 444 479 test_cmp expect output 445 480 ' 446 481 447 test_expect_success 'alternative GIT_CONFIG (--file)' \ 448 'git config --file other-config -l > output && cmp output expect' 482 test_expect_success 'alternative GIT_CONFIG (--file)' ' 483 git config --file other-config --list >output && 484 test_cmp expect output 485 ' 486 487 test_expect_success 'alternative GIT_CONFIG (--file=-)' ' 488 git config --file - --list <other-config >output && 489 test_cmp expect output 490 ' 491 492 test_expect_success 'setting a value in stdin is an error' ' 493 test_must_fail git config --file - some.value foo 494 ' 495 496 test_expect_success 'editing stdin is an error' ' 497 test_must_fail git config --file - --edit 498 ' 449 499 450 500 test_expect_success 'refer config from subdirectory' ' … … 452 502 ( 453 503 cd x && 454 echo strasse >expect 504 echo strasse >expect && 455 505 git config --get --file ../other-config ein.bahn >actual && 456 506 test_cmp expect actual 457 507 ) 458 508 509 ' 510 511 test_expect_success 'refer config from subdirectory via --file' ' 512 ( 513 cd x && 514 git config --file=../other-config --get ein.bahn >actual && 515 test_cmp expect actual 516 ) 459 517 ' 460 518 … … 466 524 EOF 467 525 468 test_expect_success '--set in alternative GIT_CONFIG' '469 GIT_CONFIG=other-config gitconfig anwohner.park ausweis &&526 test_expect_success '--set in alternative file' ' 527 git config --file=other-config anwohner.park ausweis && 470 528 test_cmp expect other-config 471 529 ' … … 482 540 EOF 483 541 484 test_expect_success "rename section" \ 485 "git config --rename-section branch.eins branch.zwei" 542 test_expect_success 'rename section' ' 543 git config --rename-section branch.eins branch.zwei 544 ' 486 545 487 546 cat > expect << EOF … … 496 555 EOF 497 556 498 test_expect_success "rename succeeded" "test_cmp expect .git/config" 499 500 test_expect_success "rename non-existing section" ' 557 test_expect_success 'rename succeeded' ' 558 test_cmp expect .git/config 559 ' 560 561 test_expect_success 'rename non-existing section' ' 501 562 test_must_fail git config --rename-section \ 502 563 branch."world domination" branch.drei 503 564 ' 504 565 505 test_expect_success "rename succeeded" "test_cmp expect .git/config" 506 507 test_expect_success "rename another section" \ 508 'git config --rename-section branch."1 234 blabl/a" branch.drei' 566 test_expect_success 'rename succeeded' ' 567 test_cmp expect .git/config 568 ' 569 570 test_expect_success 'rename another section' ' 571 git config --rename-section branch."1 234 blabl/a" branch.drei 572 ' 509 573 510 574 cat > expect << EOF … … 519 583 EOF 520 584 521 test_expect_success "rename succeeded" "test_cmp expect .git/config" 585 test_expect_success 'rename succeeded' ' 586 test_cmp expect .git/config 587 ' 522 588 523 589 cat >> .git/config << EOF … … 525 591 EOF 526 592 527 test_expect_success "rename a section with a var on the same line" \ 528 'git config --rename-section branch.vier branch.zwei' 593 test_expect_success 'rename a section with a var on the same line' ' 594 git config --rename-section branch.vier branch.zwei 595 ' 529 596 530 597 cat > expect << EOF … … 541 608 EOF 542 609 543 test_expect_success "rename succeeded" "test_cmp expect .git/config" 610 test_expect_success 'rename succeeded' ' 611 test_cmp expect .git/config 612 ' 613 614 test_expect_success 'renaming empty section name is rejected' ' 615 test_must_fail git config --rename-section branch.zwei "" 616 ' 617 618 test_expect_success 'renaming to bogus section is rejected' ' 619 test_must_fail git config --rename-section branch.zwei "bogus name" 620 ' 544 621 545 622 cat >> .git/config << EOF … … 547 624 EOF 548 625 549 test_expect_success "remove section" "git config --remove-section branch.zwei" 626 test_expect_success 'remove section' ' 627 git config --remove-section branch.zwei 628 ' 550 629 551 630 cat > expect << EOF … … 556 635 EOF 557 636 558 test_expect_success "section was removed properly" \ 559 "test_cmp expect .git/config" 637 test_expect_success 'section was removed properly' ' 638 test_cmp expect .git/config 639 ' 560 640 561 641 cat > expect << EOF … … 568 648 569 649 test_expect_success 'section ending' ' 570 571 650 rm -f .git/config && 572 651 git config gitcvs.enabled true && … … 578 657 579 658 test_expect_success numbers ' 580 581 659 git config kilo.gram 1k && 582 660 git config mega.ton 1m && 583 k=$(git config --int --get kilo.gram) && 584 test z1024 = "z$k" && 585 m=$(git config --int --get mega.ton) && 586 test z1048576 = "z$m" 587 ' 588 589 cat > expect <<EOF 590 fatal: bad config value for 'aninvalid.unit' in .git/config 591 EOF 661 echo 1024 >expect && 662 echo 1048576 >>expect && 663 git config --int --get kilo.gram >actual && 664 git config --int --get mega.ton >>actual && 665 test_cmp expect actual 666 ' 667 668 test_expect_success '--int is at least 64 bits' ' 669 git config giga.watts 121g && 670 echo 129922760704 >expect && 671 git config --int --get giga.watts >actual && 672 test_cmp expect actual 673 ' 592 674 593 675 test_expect_success 'invalid unit' ' 594 595 676 git config aninvalid.unit "1auto" && 596 s=$(git config aninvalid.unit)&&597 test "z1auto" = "z$s"&&598 if git config --int --get aninvalid.unit 2>actual599 then600 echo config should have failed601 false602 fi&&603 cmp actual expect677 echo 1auto >expect && 678 git config aninvalid.unit >actual && 679 test_cmp expect actual && 680 cat >expect <<-\EOF 681 fatal: bad numeric config value '\''1auto'\'' for '\''aninvalid.unit'\'' in .git/config: invalid unit 682 EOF 683 test_must_fail git config --int --get aninvalid.unit 2>actual && 684 test_i18ncmp expect actual 604 685 ' 605 686 … … 631 712 git config --bool --get bool.false$i >>result 632 713 done && 633 cmp expect result'714 test_cmp expect result' 634 715 635 716 test_expect_success 'invalid bool (--get)' ' … … 665 746 git config --bool bool.false3 nO && 666 747 git config --bool bool.false4 FALSE && 667 cmp expect .git/config'748 test_cmp expect .git/config' 668 749 669 750 cat > expect <<\EOF … … 680 761 git config --int int.val2 -1 && 681 762 git config --int int.val3 5m && 682 cmp expect .git/config' 683 684 cat >expect <<\EOF 685 [bool] 686 true1 = true 763 test_cmp expect .git/config 764 ' 765 766 test_expect_success 'get --bool-or-int' ' 767 cat >.git/config <<-\EOF && 768 [bool] 769 true1 687 770 true2 = true 688 false1 = false 689 false2 = false 690 [int] 771 false = false 772 [int] 691 773 int1 = 0 692 774 int2 = 1 693 775 int3 = -1 694 EOF 695 696 test_expect_success 'get --bool-or-int' ' 697 rm -f .git/config && 698 ( 699 echo "[bool]" 700 echo true1 701 echo true2 = true 702 echo false = false 703 echo "[int]" 704 echo int1 = 0 705 echo int2 = 1 706 echo int3 = -1 707 ) >>.git/config && 708 test $(git config --bool-or-int bool.true1) = true && 709 test $(git config --bool-or-int bool.true2) = true && 710 test $(git config --bool-or-int bool.false) = false && 711 test $(git config --bool-or-int int.int1) = 0 && 712 test $(git config --bool-or-int int.int2) = 1 && 713 test $(git config --bool-or-int int.int3) = -1 714 776 EOF 777 cat >expect <<-\EOF && 778 true 779 true 780 false 781 0 782 1 783 -1 784 EOF 785 { 786 git config --bool-or-int bool.true1 && 787 git config --bool-or-int bool.true2 && 788 git config --bool-or-int bool.false && 789 git config --bool-or-int int.int1 && 790 git config --bool-or-int int.int2 && 791 git config --bool-or-int int.int3 792 } >actual && 793 test_cmp expect actual 715 794 ' 716 795 … … 788 867 ' 789 868 869 test_expect_success 'get --path barfs on boolean variable' ' 870 echo "[path]bool" >.git/config && 871 test_must_fail git config --get --path path.bool 872 ' 873 790 874 cat > expect << EOF 791 875 [quote] … … 829 913 test_expect_success 'value continued on next line' ' 830 914 git config --list > result && 831 cmp result expect915 test_cmp result expect 832 916 ' 833 917 … … 865 949 test_expect_success 'inner whitespace kept verbatim' ' 866 950 git config section.val "foo bar" && 867 test "z$(git config section.val)" = "zfoo bar" 951 echo "foo bar" >expect && 952 git config section.val >actual && 953 test_cmp expect actual 868 954 ' 869 955 870 956 test_expect_success SYMLINKS 'symlinked configuration' ' 871 872 957 ln -s notyet myconfig && 873 GIT_CONFIG=myconfig gitconfig test.frotz nitfol &&958 git config --file=myconfig test.frotz nitfol && 874 959 test -h myconfig && 875 960 test -f notyet && 876 test "z$( GIT_CONFIG=notyet git configtest.frotz)" = znitfol &&877 GIT_CONFIG=myconfig gitconfig test.xyzzy rezrov &&961 test "z$(git config --file=notyet test.frotz)" = znitfol && 962 git config --file=myconfig test.xyzzy rezrov && 878 963 test -h myconfig && 879 964 test -f notyet && 880 test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol && 881 test "z$(GIT_CONFIG=notyet git config test.xyzzy)" = zrezrov 882 965 cat >expect <<-\EOF && 966 nitfol 967 rezrov 968 EOF 969 { 970 git config --file=notyet test.frotz && 971 git config --file=notyet test.xyzzy 972 } >actual && 973 test_cmp expect actual 883 974 ' 884 975 885 976 test_expect_success 'nonexistent configuration' ' 886 ( 887 GIT_CONFIG=doesnotexist && 888 export GIT_CONFIG && 889 test_must_fail git config --list && 890 test_must_fail git config test.xyzzy 891 ) 977 test_must_fail git config --file=doesnotexist --list && 978 test_must_fail git config --file=doesnotexist test.xyzzy 892 979 ' 893 980 … … 895 982 ln -s doesnotexist linktonada && 896 983 ln -s linktonada linktolinktonada && 897 ( 898 GIT_CONFIG=linktonada && 899 export GIT_CONFIG && 900 test_must_fail git config --list && 901 GIT_CONFIG=linktolinktonada && 902 test_must_fail git config --list 903 ) 984 test_must_fail git config --file=linktonada --list && 985 test_must_fail git config --file=linktolinktonada --list 904 986 ' 905 987 … … 912 994 git config branch.master.mergeoptions 'echo \"' && 913 995 test_must_fail git merge master 914 996 " 915 997 916 998 test_expect_success 'git -c "key=value" support' ' 917 test "z$(git -c core.name=value config core.name)" = zvalue && 918 test "z$(git -c foo.CamelCase=value config foo.camelcase)" = zvalue && 919 test "z$(git -c foo.flag config --bool foo.flag)" = ztrue && 999 cat >expect <<-\EOF && 1000 value 1001 value 1002 true 1003 EOF 1004 { 1005 git -c core.name=value config core.name && 1006 git -c foo.CamelCase=value config foo.camelcase && 1007 git -c foo.flag config --bool foo.flag 1008 } >actual && 1009 test_cmp expect actual && 920 1010 test_must_fail git -c name=value config core.name 921 1011 ' … … 961 1051 ' 962 1052 1053 test_expect_success 'git config --edit works' ' 1054 git config -f tmp test.value no && 1055 echo test.value=yes >expect && 1056 GIT_EDITOR="echo [test]value=yes >" git config -f tmp --edit && 1057 git config -f tmp --list >actual && 1058 test_cmp expect actual 1059 ' 1060 1061 test_expect_success 'git config --edit respects core.editor' ' 1062 git config -f tmp test.value no && 1063 echo test.value=yes >expect && 1064 test_config core.editor "echo [test]value=yes >" && 1065 git config -f tmp --edit && 1066 git config -f tmp --list >actual && 1067 test_cmp expect actual 1068 ' 1069 963 1070 # malformed configuration files 964 1071 test_expect_success 'barf on syntax error' ' … … 992 1099 ' 993 1100 1101 test_expect_success 'urlmatch' ' 1102 cat >.git/config <<-\EOF && 1103 [http] 1104 sslVerify 1105 [http "https://weak.example.com"] 1106 sslVerify = false 1107 cookieFile = /tmp/cookie.txt 1108 EOF 1109 1110 echo true >expect && 1111 git config --bool --get-urlmatch http.SSLverify https://good.example.com >actual && 1112 test_cmp expect actual && 1113 1114 echo false >expect && 1115 git config --bool --get-urlmatch http.sslverify https://weak.example.com >actual && 1116 test_cmp expect actual && 1117 1118 { 1119 echo http.cookiefile /tmp/cookie.txt && 1120 echo http.sslverify false 1121 } >expect && 1122 git config --get-urlmatch HTTP https://weak.example.com >actual && 1123 test_cmp expect actual 1124 ' 1125 1126 # good section hygiene 1127 test_expect_failure 'unsetting the last key in a section removes header' ' 1128 cat >.git/config <<-\EOF && 1129 # some generic comment on the configuration file itself 1130 # a comment specific to this "section" section. 1131 [section] 1132 # some intervening lines 1133 # that should also be dropped 1134 1135 key = value 1136 # please be careful when you update the above variable 1137 EOF 1138 1139 cat >expect <<-\EOF && 1140 # some generic comment on the configuration file itself 1141 EOF 1142 1143 git config --unset section.key && 1144 test_cmp expect .git/config 1145 ' 1146 1147 test_expect_failure 'adding a key into an empty section reuses header' ' 1148 cat >.git/config <<-\EOF && 1149 [section] 1150 EOF 1151 1152 q_to_tab >expect <<-\EOF && 1153 [section] 1154 Qkey = value 1155 EOF 1156 1157 git config section.key value 1158 test_cmp expect .git/config 1159 ' 1160 994 1161 test_done
Note:
See TracChangeset
for help on using the changeset viewer.