Ignore:
Timestamp:
Jun 23, 2014, 9:45:51 PM (11 years ago)
Author:
dmik
Message:

git: Merge version 2.0.0 from vendor to dmik branch.

Location:
git/branches/dmik
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • git/branches/dmik

  • TabularUnified git/branches/dmik/t/t1300-repo-config.sh

    r626 r782  
    5656'
    5757
    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'
     58test_expect_success 'replace with non-match' '
     59        git config core.penguin kingpin !blue
     60'
     61
     62test_expect_success 'replace with non-match (actually matching)' '
     63        git config core.penguin "very blue" !kingpin
     64'
    6365
    6466cat > expect << EOF
     
    109111EOF
    110112
    111 test_expect_success 'unset with cont. lines' \
    112         'git config --unset beta.baz'
     113test_expect_success 'unset with cont. lines' '
     114        git config --unset beta.baz
     115'
    113116
    114117cat > expect <<\EOF
     
    134137cp .git/config .git/config2
    135138
    136 test_expect_success 'multiple unset' \
    137         'git config --unset-all beta.haha'
     139test_expect_success 'multiple unset' '
     140        git config --unset-all beta.haha
     141'
    138142
    139143cat > expect << EOF
     
    146150EOF
    147151
    148 test_expect_success 'multiple unset is correct' 'test_cmp expect .git/config'
     152test_expect_success 'multiple unset is correct' '
     153        test_cmp expect .git/config
     154'
    149155
    150156cp .git/config2 .git/config
     
    157163rm .git/config2
    158164
    159 test_expect_success '--replace-all' \
    160         'git config --replace-all beta.haha gamma'
     165test_expect_success '--replace-all' '
     166        git config --replace-all beta.haha gamma
     167'
    161168
    162169cat > expect << EOF
     
    170177EOF
    171178
    172 test_expect_success 'all replaced' 'test_cmp expect .git/config'
     179test_expect_success 'all replaced' '
     180        test_cmp expect .git/config
     181'
    173182
    174183cat > expect << EOF
     
    201210'
    202211
    203 test_expect_success 'get value' 'test alpha = $(git config beta.haha)'
     212test_expect_success 'get value' '
     213        echo alpha >expect &&
     214        git config beta.haha >actual &&
     215        test_cmp expect actual
     216'
    204217
    205218cat > expect << EOF
     
    232245'
    233246
    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'
     247test_expect_success 'non-match' '
     248        git config --get nextsection.nonewline !for
     249'
     250
     251test_expect_success 'non-match value' '
     252        echo wow >expect &&
     253        git config --get nextsection.nonewline !for >actual &&
     254        test_cmp expect actual
     255'
     256
     257test_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
     263test_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'
    246271
    247272cat > expect << EOF
     
    260285'
    261286
    262 test_expect_success 'ambiguous value' '
    263         test_must_fail git config nextsection.nonewline
    264 '
    265 
    266287test_expect_success 'ambiguous unset' '
    267288        test_must_fail git config --unset nextsection.nonewline
     
    291312test_expect_success 'correct key' 'git config 123456.a123 987'
    292313
    293 test_expect_success 'hierarchical section' \
    294         'git config Version.1.2.3eX.Alpha beta'
     314test_expect_success 'hierarchical section' '
     315        git config Version.1.2.3eX.Alpha beta
     316'
    295317
    296318cat > expect << EOF
     
    308330EOF
    309331
    310 test_expect_success 'hierarchical section value' 'test_cmp expect .git/config'
     332test_expect_success 'hierarchical section value' '
     333        test_cmp expect .git/config
     334'
    311335
    312336cat > expect << EOF
     
    317341EOF
    318342
    319 test_expect_success 'working --list' \
    320         'git config --list > output && cmp output expect'
    321 
     343test_expect_success 'working --list' '
     344        git config --list > output &&
     345        test_cmp expect output
     346'
    322347cat > expect << EOF
    323348EOF
     
    333358EOF
    334359
    335 test_expect_success '--get-regexp' \
    336         'git config --get-regexp in > output && cmp output expect'
     360test_expect_success '--get-regexp' '
     361        git config --get-regexp in >output &&
     362        test_cmp expect output
     363'
    337364
    338365cat > expect << EOF
     
    354381EOF
    355382
    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 ^$'
     383test_expect_success 'get variable with no value' '
     384        git config --get novalue.variable ^$
     385'
     386
     387test_expect_success 'get variable with empty value' '
     388        git config --get emptyvalue.variable ^$
     389'
    361390
    362391echo novalue.variable > expect
    363392
    364 test_expect_success 'get-regexp variable with no value' \
    365         'git config --get-regexp novalue > output &&
    366          cmp output expect'
     393test_expect_success 'get-regexp variable with no value' '
     394        git config --get-regexp novalue > output &&
     395        test_cmp expect output
     396'
    367397
    368398echo 'novalue.variable true' > expect
    369399
    370 test_expect_success 'get-regexp --bool variable with no value' \
    371         'git config --bool --get-regexp novalue > output &&
    372          cmp output expect'
     400test_expect_success 'get-regexp --bool variable with no value' '
     401        git config --bool --get-regexp novalue > output &&
     402        test_cmp expect output
     403'
    373404
    374405echo 'emptyvalue.variable ' > expect
    375406
    376 test_expect_success 'get-regexp variable with empty value' \
    377         'git config --get-regexp emptyvalue > output &&
    378          cmp output expect'
     407test_expect_success 'get-regexp variable with empty value' '
     408        git config --get-regexp emptyvalue > output &&
     409        test_cmp expect output
     410'
    379411
    380412echo true > expect
    381413
    382 test_expect_success 'get bool variable with no value' \
    383         'git config --bool novalue.variable > output &&
    384          cmp output expect'
     414test_expect_success 'get bool variable with no value' '
     415        git config --bool novalue.variable > output &&
     416        test_cmp expect output
     417'
    385418
    386419echo false > expect
    387420
    388 test_expect_success 'get bool variable with empty value' \
    389         'git config --bool emptyvalue.variable > output &&
    390          cmp output expect'
     421test_expect_success 'get bool variable with empty value' '
     422        git config --bool emptyvalue.variable > output &&
     423        test_cmp expect output
     424'
    391425
    392426test_expect_success 'no arguments, but no crash' '
    393427        test_must_fail git config >output 2>&1 &&
    394         grep usage output
     428        test_i18ngrep usage output
    395429'
    396430
     
    428462'
    429463
    430 test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' \
    431         'test_must_fail git config --file non-existing-config -l'
     464test_expect_success 'alternative --file (non-existing file should fail)' '
     465        test_must_fail git config --file non-existing-config -l
     466'
    432467
    433468cat > other-config << EOF
     
    441476
    442477test_expect_success 'alternative GIT_CONFIG' '
    443         GIT_CONFIG=other-config git config -l >output &&
     478        GIT_CONFIG=other-config git config --list >output &&
    444479        test_cmp expect output
    445480'
    446481
    447 test_expect_success 'alternative GIT_CONFIG (--file)' \
    448         'git config --file other-config -l > output && cmp output expect'
     482test_expect_success 'alternative GIT_CONFIG (--file)' '
     483        git config --file other-config --list >output &&
     484        test_cmp expect output
     485'
     486
     487test_expect_success 'alternative GIT_CONFIG (--file=-)' '
     488        git config --file - --list <other-config >output &&
     489        test_cmp expect output
     490'
     491
     492test_expect_success 'setting a value in stdin is an error' '
     493        test_must_fail git config --file - some.value foo
     494'
     495
     496test_expect_success 'editing stdin is an error' '
     497        test_must_fail git config --file - --edit
     498'
    449499
    450500test_expect_success 'refer config from subdirectory' '
     
    452502        (
    453503                cd x &&
    454                 echo strasse >expect
     504                echo strasse >expect &&
    455505                git config --get --file ../other-config ein.bahn >actual &&
    456506                test_cmp expect actual
    457507        )
    458508
     509'
     510
     511test_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        )
    459517'
    460518
     
    466524EOF
    467525
    468 test_expect_success '--set in alternative GIT_CONFIG' '
    469         GIT_CONFIG=other-config git config anwohner.park ausweis &&
     526test_expect_success '--set in alternative file' '
     527        git config --file=other-config anwohner.park ausweis &&
    470528        test_cmp expect other-config
    471529'
     
    482540EOF
    483541
    484 test_expect_success "rename section" \
    485         "git config --rename-section branch.eins branch.zwei"
     542test_expect_success 'rename section' '
     543        git config --rename-section branch.eins branch.zwei
     544'
    486545
    487546cat > expect << EOF
     
    496555EOF
    497556
    498 test_expect_success "rename succeeded" "test_cmp expect .git/config"
    499 
    500 test_expect_success "rename non-existing section" '
     557test_expect_success 'rename succeeded' '
     558        test_cmp expect .git/config
     559'
     560
     561test_expect_success 'rename non-existing section' '
    501562        test_must_fail git config --rename-section \
    502563                branch."world domination" branch.drei
    503564'
    504565
    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'
     566test_expect_success 'rename succeeded' '
     567        test_cmp expect .git/config
     568'
     569
     570test_expect_success 'rename another section' '
     571        git config --rename-section branch."1 234 blabl/a" branch.drei
     572'
    509573
    510574cat > expect << EOF
     
    519583EOF
    520584
    521 test_expect_success "rename succeeded" "test_cmp expect .git/config"
     585test_expect_success 'rename succeeded' '
     586        test_cmp expect .git/config
     587'
    522588
    523589cat >> .git/config << EOF
     
    525591EOF
    526592
    527 test_expect_success "rename a section with a var on the same line" \
    528         'git config --rename-section branch.vier branch.zwei'
     593test_expect_success 'rename a section with a var on the same line' '
     594        git config --rename-section branch.vier branch.zwei
     595'
    529596
    530597cat > expect << EOF
     
    541608EOF
    542609
    543 test_expect_success "rename succeeded" "test_cmp expect .git/config"
     610test_expect_success 'rename succeeded' '
     611        test_cmp expect .git/config
     612'
     613
     614test_expect_success 'renaming empty section name is rejected' '
     615        test_must_fail git config --rename-section branch.zwei ""
     616'
     617
     618test_expect_success 'renaming to bogus section is rejected' '
     619        test_must_fail git config --rename-section branch.zwei "bogus name"
     620'
    544621
    545622cat >> .git/config << EOF
     
    547624EOF
    548625
    549 test_expect_success "remove section" "git config --remove-section branch.zwei"
     626test_expect_success 'remove section' '
     627        git config --remove-section branch.zwei
     628'
    550629
    551630cat > expect << EOF
     
    556635EOF
    557636
    558 test_expect_success "section was removed properly" \
    559         "test_cmp expect .git/config"
     637test_expect_success 'section was removed properly' '
     638        test_cmp expect .git/config
     639'
    560640
    561641cat > expect << EOF
     
    568648
    569649test_expect_success 'section ending' '
    570 
    571650        rm -f .git/config &&
    572651        git config gitcvs.enabled true &&
     
    578657
    579658test_expect_success numbers '
    580 
    581659        git config kilo.gram 1k &&
    582660        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
     668test_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'
    592674
    593675test_expect_success 'invalid unit' '
    594 
    595676        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>actual
    599         then
    600                 echo config should have failed
    601                 false
    602         fi &&
    603         cmp actual expect
     677        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
    604685'
    605686
     
    631712            git config --bool --get bool.false$i >>result
    632713        done &&
    633         cmp expect result'
     714        test_cmp expect result'
    634715
    635716test_expect_success 'invalid bool (--get)' '
     
    665746        git config --bool bool.false3 nO &&
    666747        git config --bool bool.false4 FALSE &&
    667         cmp expect .git/config'
     748        test_cmp expect .git/config'
    668749
    669750cat > expect <<\EOF
     
    680761        git config --int int.val2 -1 &&
    681762        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
     766test_expect_success 'get --bool-or-int' '
     767        cat >.git/config <<-\EOF &&
     768        [bool]
     769        true1
    687770        true2 = true
    688         false1 = false
    689         false2 = false
    690 [int]
     771        false = false
     772        [int]
    691773        int1 = 0
    692774        int2 = 1
    693775        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
    715794'
    716795
     
    788867'
    789868
     869test_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
    790874cat > expect << EOF
    791875[quote]
     
    829913test_expect_success 'value continued on next line' '
    830914        git config --list > result &&
    831         cmp result expect
     915        test_cmp result expect
    832916'
    833917
     
    865949test_expect_success 'inner whitespace kept verbatim' '
    866950        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
    868954'
    869955
    870956test_expect_success SYMLINKS 'symlinked configuration' '
    871 
    872957        ln -s notyet myconfig &&
    873         GIT_CONFIG=myconfig git config test.frotz nitfol &&
     958        git config --file=myconfig test.frotz nitfol &&
    874959        test -h myconfig &&
    875960        test -f notyet &&
    876         test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol &&
    877         GIT_CONFIG=myconfig git config test.xyzzy rezrov &&
     961        test "z$(git config --file=notyet test.frotz)" = znitfol &&
     962        git config --file=myconfig test.xyzzy rezrov &&
    878963        test -h myconfig &&
    879964        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
    883974'
    884975
    885976test_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
    892979'
    893980
     
    895982        ln -s doesnotexist linktonada &&
    896983        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
    904986'
    905987
     
    912994        git config branch.master.mergeoptions 'echo \"' &&
    913995        test_must_fail git merge master
    914         "
     996"
    915997
    916998test_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 &&
    9201010        test_must_fail git -c name=value config core.name
    9211011'
     
    9611051'
    9621052
     1053test_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
     1061test_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
    9631070# malformed configuration files
    9641071test_expect_success 'barf on syntax error' '
     
    9921099'
    9931100
     1101test_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
     1127test_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
     1147test_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
    9941161test_done
Note: See TracChangeset for help on using the changeset viewer.