t / t1300-repo-config.shon commit Merge branch 'jn/gitweb-manpages' (380f26c)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Johannes Schindelin
   4#
   5
   6test_description='Test git config in different settings'
   7
   8. ./test-lib.sh
   9
  10test_expect_success 'clear default config' '
  11        rm -f .git/config
  12'
  13
  14cat > expect << EOF
  15[core]
  16        penguin = little blue
  17EOF
  18test_expect_success 'initial' '
  19        git config core.penguin "little blue" &&
  20        test_cmp expect .git/config
  21'
  22
  23cat > expect << EOF
  24[core]
  25        penguin = little blue
  26        Movie = BadPhysics
  27EOF
  28test_expect_success 'mixed case' '
  29        git config Core.Movie BadPhysics &&
  30        test_cmp expect .git/config
  31'
  32
  33cat > expect << EOF
  34[core]
  35        penguin = little blue
  36        Movie = BadPhysics
  37[Cores]
  38        WhatEver = Second
  39EOF
  40test_expect_success 'similar section' '
  41        git config Cores.WhatEver Second
  42        test_cmp expect .git/config
  43'
  44
  45cat > expect << EOF
  46[core]
  47        penguin = little blue
  48        Movie = BadPhysics
  49        UPPERCASE = true
  50[Cores]
  51        WhatEver = Second
  52EOF
  53test_expect_success 'uppercase section' '
  54        git config CORE.UPPERCASE true &&
  55        test_cmp expect .git/config
  56'
  57
  58test_expect_success 'replace with non-match' \
  59        'git config core.penguin kingpin !blue'
  60
  61test_expect_success 'replace with non-match (actually matching)' \
  62        'git config core.penguin "very blue" !kingpin'
  63
  64cat > expect << EOF
  65[core]
  66        penguin = very blue
  67        Movie = BadPhysics
  68        UPPERCASE = true
  69        penguin = kingpin
  70[Cores]
  71        WhatEver = Second
  72EOF
  73
  74test_expect_success 'non-match result' 'test_cmp expect .git/config'
  75
  76test_expect_success 'find mixed-case key by canonical name' '
  77        echo Second >expect &&
  78        git config cores.whatever >actual &&
  79        test_cmp expect actual
  80'
  81
  82test_expect_success 'find mixed-case key by non-canonical name' '
  83        echo Second >expect &&
  84        git config CoReS.WhAtEvEr >actual &&
  85        test_cmp expect actual
  86'
  87
  88test_expect_success 'subsections are not canonicalized by git-config' '
  89        cat >>.git/config <<-\EOF &&
  90        [section.SubSection]
  91        key = one
  92        [section "SubSection"]
  93        key = two
  94        EOF
  95        echo one >expect &&
  96        git config section.subsection.key >actual &&
  97        test_cmp expect actual &&
  98        echo two >expect &&
  99        git config section.SubSection.key >actual &&
 100        test_cmp expect actual
 101'
 102
 103cat > .git/config <<\EOF
 104[alpha]
 105bar = foo
 106[beta]
 107baz = multiple \
 108lines
 109EOF
 110
 111test_expect_success 'unset with cont. lines' \
 112        'git config --unset beta.baz'
 113
 114cat > expect <<\EOF
 115[alpha]
 116bar = foo
 117[beta]
 118EOF
 119
 120test_expect_success 'unset with cont. lines is correct' 'test_cmp expect .git/config'
 121
 122cat > .git/config << EOF
 123[beta] ; silly comment # another comment
 124noIndent= sillyValue ; 'nother silly comment
 125
 126# empty line
 127                ; comment
 128                haha   ="beta" # last silly comment
 129haha = hello
 130        haha = bello
 131[nextSection] noNewline = ouch
 132EOF
 133
 134cp .git/config .git/config2
 135
 136test_expect_success 'multiple unset' \
 137        'git config --unset-all beta.haha'
 138
 139cat > expect << EOF
 140[beta] ; silly comment # another comment
 141noIndent= sillyValue ; 'nother silly comment
 142
 143# empty line
 144                ; comment
 145[nextSection] noNewline = ouch
 146EOF
 147
 148test_expect_success 'multiple unset is correct' 'test_cmp expect .git/config'
 149
 150cp .git/config2 .git/config
 151
 152test_expect_success '--replace-all missing value' '
 153        test_must_fail git config --replace-all beta.haha &&
 154        test_cmp .git/config2 .git/config
 155'
 156
 157rm .git/config2
 158
 159test_expect_success '--replace-all' \
 160        'git config --replace-all beta.haha gamma'
 161
 162cat > expect << EOF
 163[beta] ; silly comment # another comment
 164noIndent= sillyValue ; 'nother silly comment
 165
 166# empty line
 167                ; comment
 168        haha = gamma
 169[nextSection] noNewline = ouch
 170EOF
 171
 172test_expect_success 'all replaced' 'test_cmp expect .git/config'
 173
 174cat > expect << EOF
 175[beta] ; silly comment # another comment
 176noIndent= sillyValue ; 'nother silly comment
 177
 178# empty line
 179                ; comment
 180        haha = alpha
 181[nextSection] noNewline = ouch
 182EOF
 183test_expect_success 'really mean test' '
 184        git config beta.haha alpha &&
 185        test_cmp expect .git/config
 186'
 187
 188cat > expect << EOF
 189[beta] ; silly comment # another comment
 190noIndent= sillyValue ; 'nother silly comment
 191
 192# empty line
 193                ; comment
 194        haha = alpha
 195[nextSection]
 196        nonewline = wow
 197EOF
 198test_expect_success 'really really mean test' '
 199        git config nextsection.nonewline wow &&
 200        test_cmp expect .git/config
 201'
 202
 203test_expect_success 'get value' 'test alpha = $(git config beta.haha)'
 204
 205cat > expect << EOF
 206[beta] ; silly comment # another comment
 207noIndent= sillyValue ; 'nother silly comment
 208
 209# empty line
 210                ; comment
 211[nextSection]
 212        nonewline = wow
 213EOF
 214test_expect_success 'unset' '
 215        git config --unset beta.haha &&
 216        test_cmp expect .git/config
 217'
 218
 219cat > expect << EOF
 220[beta] ; silly comment # another comment
 221noIndent= sillyValue ; 'nother silly comment
 222
 223# empty line
 224                ; comment
 225[nextSection]
 226        nonewline = wow
 227        NoNewLine = wow2 for me
 228EOF
 229test_expect_success 'multivar' '
 230        git config nextsection.NoNewLine "wow2 for me" "for me$" &&
 231        test_cmp expect .git/config
 232'
 233
 234test_expect_success 'non-match' \
 235        'git config --get nextsection.nonewline !for'
 236
 237test_expect_success 'non-match value' \
 238        'test wow = $(git config --get nextsection.nonewline !for)'
 239
 240test_expect_success 'ambiguous get' '
 241        test_must_fail git config --get nextsection.nonewline
 242'
 243
 244test_expect_success 'get multivar' \
 245        'git config --get-all nextsection.nonewline'
 246
 247cat > expect << EOF
 248[beta] ; silly comment # another comment
 249noIndent= sillyValue ; 'nother silly comment
 250
 251# empty line
 252                ; comment
 253[nextSection]
 254        nonewline = wow3
 255        NoNewLine = wow2 for me
 256EOF
 257test_expect_success 'multivar replace' '
 258        git config nextsection.nonewline "wow3" "wow$" &&
 259        test_cmp expect .git/config
 260'
 261
 262test_expect_success 'ambiguous value' '
 263        test_must_fail git config nextsection.nonewline
 264'
 265
 266test_expect_success 'ambiguous unset' '
 267        test_must_fail git config --unset nextsection.nonewline
 268'
 269
 270test_expect_success 'invalid unset' '
 271        test_must_fail git config --unset somesection.nonewline
 272'
 273
 274cat > expect << EOF
 275[beta] ; silly comment # another comment
 276noIndent= sillyValue ; 'nother silly comment
 277
 278# empty line
 279                ; comment
 280[nextSection]
 281        NoNewLine = wow2 for me
 282EOF
 283
 284test_expect_success 'multivar unset' '
 285        git config --unset nextsection.nonewline "wow3$" &&
 286        test_cmp expect .git/config
 287'
 288
 289test_expect_success 'invalid key' 'test_must_fail git config inval.2key blabla'
 290
 291test_expect_success 'correct key' 'git config 123456.a123 987'
 292
 293test_expect_success 'hierarchical section' \
 294        'git config Version.1.2.3eX.Alpha beta'
 295
 296cat > expect << EOF
 297[beta] ; silly comment # another comment
 298noIndent= sillyValue ; 'nother silly comment
 299
 300# empty line
 301                ; comment
 302[nextSection]
 303        NoNewLine = wow2 for me
 304[123456]
 305        a123 = 987
 306[Version "1.2.3eX"]
 307        Alpha = beta
 308EOF
 309
 310test_expect_success 'hierarchical section value' 'test_cmp expect .git/config'
 311
 312cat > expect << EOF
 313beta.noindent=sillyValue
 314nextsection.nonewline=wow2 for me
 315123456.a123=987
 316version.1.2.3eX.alpha=beta
 317EOF
 318
 319test_expect_success 'working --list' \
 320        'git config --list > output && cmp output expect'
 321
 322cat > expect << EOF
 323EOF
 324
 325test_expect_success '--list without repo produces empty output' '
 326        git --git-dir=nonexistent config --list >output &&
 327        test_cmp expect output
 328'
 329
 330cat > expect << EOF
 331beta.noindent sillyValue
 332nextsection.nonewline wow2 for me
 333EOF
 334
 335test_expect_success '--get-regexp' \
 336        'git config --get-regexp in > output && cmp output expect'
 337
 338cat > expect << EOF
 339wow2 for me
 340wow4 for you
 341EOF
 342
 343test_expect_success '--add' '
 344        git config --add nextsection.nonewline "wow4 for you" &&
 345        git config --get-all nextsection.nonewline > output &&
 346        test_cmp expect output
 347'
 348
 349cat > .git/config << EOF
 350[novalue]
 351        variable
 352[emptyvalue]
 353        variable =
 354EOF
 355
 356test_expect_success 'get variable with no value' \
 357        'git config --get novalue.variable ^$'
 358
 359test_expect_success 'get variable with empty value' \
 360        'git config --get emptyvalue.variable ^$'
 361
 362echo novalue.variable > expect
 363
 364test_expect_success 'get-regexp variable with no value' \
 365        'git config --get-regexp novalue > output &&
 366         cmp output expect'
 367
 368echo 'novalue.variable true' > expect
 369
 370test_expect_success 'get-regexp --bool variable with no value' \
 371        'git config --bool --get-regexp novalue > output &&
 372         cmp output expect'
 373
 374echo 'emptyvalue.variable ' > expect
 375
 376test_expect_success 'get-regexp variable with empty value' \
 377        'git config --get-regexp emptyvalue > output &&
 378         cmp output expect'
 379
 380echo true > expect
 381
 382test_expect_success 'get bool variable with no value' \
 383        'git config --bool novalue.variable > output &&
 384         cmp output expect'
 385
 386echo false > expect
 387
 388test_expect_success 'get bool variable with empty value' \
 389        'git config --bool emptyvalue.variable > output &&
 390         cmp output expect'
 391
 392test_expect_success 'no arguments, but no crash' '
 393        test_must_fail git config >output 2>&1 &&
 394        grep usage output
 395'
 396
 397cat > .git/config << EOF
 398[a.b]
 399        c = d
 400EOF
 401
 402cat > expect << EOF
 403[a.b]
 404        c = d
 405[a]
 406        x = y
 407EOF
 408
 409test_expect_success 'new section is partial match of another' '
 410        git config a.x y &&
 411        test_cmp expect .git/config
 412'
 413
 414cat > expect << EOF
 415[a.b]
 416        c = d
 417[a]
 418        x = y
 419        b = c
 420[b]
 421        x = y
 422EOF
 423
 424test_expect_success 'new variable inserts into proper section' '
 425        git config b.x y &&
 426        git config a.b c &&
 427        test_cmp expect .git/config
 428'
 429
 430test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' \
 431        'test_must_fail git config --file non-existing-config -l'
 432
 433cat > other-config << EOF
 434[ein]
 435        bahn = strasse
 436EOF
 437
 438cat > expect << EOF
 439ein.bahn=strasse
 440EOF
 441
 442test_expect_success 'alternative GIT_CONFIG' '
 443        GIT_CONFIG=other-config git config -l >output &&
 444        test_cmp expect output
 445'
 446
 447test_expect_success 'alternative GIT_CONFIG (--file)' \
 448        'git config --file other-config -l > output && cmp output expect'
 449
 450test_expect_success 'refer config from subdirectory' '
 451        mkdir x &&
 452        (
 453                cd x &&
 454                echo strasse >expect
 455                git config --get --file ../other-config ein.bahn >actual &&
 456                test_cmp expect actual
 457        )
 458
 459'
 460
 461cat > expect << EOF
 462[ein]
 463        bahn = strasse
 464[anwohner]
 465        park = ausweis
 466EOF
 467
 468test_expect_success '--set in alternative GIT_CONFIG' '
 469        GIT_CONFIG=other-config git config anwohner.park ausweis &&
 470        test_cmp expect other-config
 471'
 472
 473cat > .git/config << EOF
 474# Hallo
 475        #Bello
 476[branch "eins"]
 477        x = 1
 478[branch.eins]
 479        y = 1
 480        [branch "1 234 blabl/a"]
 481weird
 482EOF
 483
 484test_expect_success "rename section" \
 485        "git config --rename-section branch.eins branch.zwei"
 486
 487cat > expect << EOF
 488# Hallo
 489        #Bello
 490[branch "zwei"]
 491        x = 1
 492[branch "zwei"]
 493        y = 1
 494        [branch "1 234 blabl/a"]
 495weird
 496EOF
 497
 498test_expect_success "rename succeeded" "test_cmp expect .git/config"
 499
 500test_expect_success "rename non-existing section" '
 501        test_must_fail git config --rename-section \
 502                branch."world domination" branch.drei
 503'
 504
 505test_expect_success "rename succeeded" "test_cmp expect .git/config"
 506
 507test_expect_success "rename another section" \
 508        'git config --rename-section branch."1 234 blabl/a" branch.drei'
 509
 510cat > expect << EOF
 511# Hallo
 512        #Bello
 513[branch "zwei"]
 514        x = 1
 515[branch "zwei"]
 516        y = 1
 517[branch "drei"]
 518weird
 519EOF
 520
 521test_expect_success "rename succeeded" "test_cmp expect .git/config"
 522
 523cat >> .git/config << EOF
 524[branch "vier"] z = 1
 525EOF
 526
 527test_expect_success "rename a section with a var on the same line" \
 528        'git config --rename-section branch.vier branch.zwei'
 529
 530cat > expect << EOF
 531# Hallo
 532        #Bello
 533[branch "zwei"]
 534        x = 1
 535[branch "zwei"]
 536        y = 1
 537[branch "drei"]
 538weird
 539[branch "zwei"]
 540        z = 1
 541EOF
 542
 543test_expect_success "rename succeeded" "test_cmp expect .git/config"
 544
 545cat >> .git/config << EOF
 546  [branch "zwei"] a = 1 [branch "vier"]
 547EOF
 548
 549test_expect_success "remove section" "git config --remove-section branch.zwei"
 550
 551cat > expect << EOF
 552# Hallo
 553        #Bello
 554[branch "drei"]
 555weird
 556EOF
 557
 558test_expect_success "section was removed properly" \
 559        "test_cmp expect .git/config"
 560
 561rm .git/config
 562
 563cat > expect << EOF
 564[gitcvs]
 565        enabled = true
 566        dbname = %Ggitcvs2.%a.%m.sqlite
 567[gitcvs "ext"]
 568        dbname = %Ggitcvs1.%a.%m.sqlite
 569EOF
 570
 571test_expect_success 'section ending' '
 572
 573        git config gitcvs.enabled true &&
 574        git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
 575        git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
 576        test_cmp expect .git/config
 577
 578'
 579
 580test_expect_success numbers '
 581
 582        git config kilo.gram 1k &&
 583        git config mega.ton 1m &&
 584        k=$(git config --int --get kilo.gram) &&
 585        test z1024 = "z$k" &&
 586        m=$(git config --int --get mega.ton) &&
 587        test z1048576 = "z$m"
 588'
 589
 590cat > expect <<EOF
 591fatal: bad config value for 'aninvalid.unit' in .git/config
 592EOF
 593
 594test_expect_success 'invalid unit' '
 595
 596        git config aninvalid.unit "1auto" &&
 597        s=$(git config aninvalid.unit) &&
 598        test "z1auto" = "z$s" &&
 599        if git config --int --get aninvalid.unit 2>actual
 600        then
 601                echo config should have failed
 602                false
 603        fi &&
 604        cmp actual expect
 605'
 606
 607cat > expect << EOF
 608true
 609false
 610true
 611false
 612true
 613false
 614true
 615false
 616EOF
 617
 618test_expect_success bool '
 619
 620        git config bool.true1 01 &&
 621        git config bool.true2 -1 &&
 622        git config bool.true3 YeS &&
 623        git config bool.true4 true &&
 624        git config bool.false1 000 &&
 625        git config bool.false2 "" &&
 626        git config bool.false3 nO &&
 627        git config bool.false4 FALSE &&
 628        rm -f result &&
 629        for i in 1 2 3 4
 630        do
 631            git config --bool --get bool.true$i >>result
 632            git config --bool --get bool.false$i >>result
 633        done &&
 634        cmp expect result'
 635
 636test_expect_success 'invalid bool (--get)' '
 637
 638        git config bool.nobool foobar &&
 639        test_must_fail git config --bool --get bool.nobool'
 640
 641test_expect_success 'invalid bool (set)' '
 642
 643        test_must_fail git config --bool bool.nobool foobar'
 644
 645rm .git/config
 646
 647cat > expect <<\EOF
 648[bool]
 649        true1 = true
 650        true2 = true
 651        true3 = true
 652        true4 = true
 653        false1 = false
 654        false2 = false
 655        false3 = false
 656        false4 = false
 657EOF
 658
 659test_expect_success 'set --bool' '
 660
 661        git config --bool bool.true1 01 &&
 662        git config --bool bool.true2 -1 &&
 663        git config --bool bool.true3 YeS &&
 664        git config --bool bool.true4 true &&
 665        git config --bool bool.false1 000 &&
 666        git config --bool bool.false2 "" &&
 667        git config --bool bool.false3 nO &&
 668        git config --bool bool.false4 FALSE &&
 669        cmp expect .git/config'
 670
 671rm .git/config
 672
 673cat > expect <<\EOF
 674[int]
 675        val1 = 1
 676        val2 = -1
 677        val3 = 5242880
 678EOF
 679
 680test_expect_success 'set --int' '
 681
 682        git config --int int.val1 01 &&
 683        git config --int int.val2 -1 &&
 684        git config --int int.val3 5m &&
 685        cmp expect .git/config'
 686
 687rm .git/config
 688
 689cat >expect <<\EOF
 690[bool]
 691        true1 = true
 692        true2 = true
 693        false1 = false
 694        false2 = false
 695[int]
 696        int1 = 0
 697        int2 = 1
 698        int3 = -1
 699EOF
 700
 701test_expect_success 'get --bool-or-int' '
 702        (
 703                echo "[bool]"
 704                echo true1
 705                echo true2 = true
 706                echo false = false
 707                echo "[int]"
 708                echo int1 = 0
 709                echo int2 = 1
 710                echo int3 = -1
 711        ) >>.git/config &&
 712        test $(git config --bool-or-int bool.true1) = true &&
 713        test $(git config --bool-or-int bool.true2) = true &&
 714        test $(git config --bool-or-int bool.false) = false &&
 715        test $(git config --bool-or-int int.int1) = 0 &&
 716        test $(git config --bool-or-int int.int2) = 1 &&
 717        test $(git config --bool-or-int int.int3) = -1
 718
 719'
 720
 721rm .git/config
 722cat >expect <<\EOF
 723[bool]
 724        true1 = true
 725        false1 = false
 726        true2 = true
 727        false2 = false
 728[int]
 729        int1 = 0
 730        int2 = 1
 731        int3 = -1
 732EOF
 733
 734test_expect_success 'set --bool-or-int' '
 735        git config --bool-or-int bool.true1 true &&
 736        git config --bool-or-int bool.false1 false &&
 737        git config --bool-or-int bool.true2 yes &&
 738        git config --bool-or-int bool.false2 no &&
 739        git config --bool-or-int int.int1 0 &&
 740        git config --bool-or-int int.int2 1 &&
 741        git config --bool-or-int int.int3 -1 &&
 742        test_cmp expect .git/config
 743'
 744
 745rm .git/config
 746
 747cat >expect <<\EOF
 748[path]
 749        home = ~/
 750        normal = /dev/null
 751        trailingtilde = foo~
 752EOF
 753
 754test_expect_success NOT_MINGW 'set --path' '
 755        git config --path path.home "~/" &&
 756        git config --path path.normal "/dev/null" &&
 757        git config --path path.trailingtilde "foo~" &&
 758        test_cmp expect .git/config'
 759
 760if test_have_prereq NOT_MINGW && test "${HOME+set}"
 761then
 762        test_set_prereq HOMEVAR
 763fi
 764
 765cat >expect <<EOF
 766$HOME/
 767/dev/null
 768foo~
 769EOF
 770
 771test_expect_success HOMEVAR 'get --path' '
 772        git config --get --path path.home > result &&
 773        git config --get --path path.normal >> result &&
 774        git config --get --path path.trailingtilde >> result &&
 775        test_cmp expect result
 776'
 777
 778cat >expect <<\EOF
 779/dev/null
 780foo~
 781EOF
 782
 783test_expect_success NOT_MINGW 'get --path copes with unset $HOME' '
 784        (
 785                unset HOME;
 786                test_must_fail git config --get --path path.home \
 787                        >result 2>msg &&
 788                git config --get --path path.normal >>result &&
 789                git config --get --path path.trailingtilde >>result
 790        ) &&
 791        grep "[Ff]ailed to expand.*~/" msg &&
 792        test_cmp expect result
 793'
 794
 795cat > expect << EOF
 796[quote]
 797        leading = " test"
 798        ending = "test "
 799        semicolon = "test;test"
 800        hash = "test#test"
 801EOF
 802test_expect_success 'quoting' '
 803        rm .git/config &&
 804        git config quote.leading " test" &&
 805        git config quote.ending "test " &&
 806        git config quote.semicolon "test;test" &&
 807        git config quote.hash "test#test" &&
 808        test_cmp expect .git/config
 809'
 810
 811test_expect_success 'key with newline' '
 812        test_must_fail git config "key.with
 813newline" 123'
 814
 815test_expect_success 'value with newline' 'git config key.sub value.with\\\
 816newline'
 817
 818cat > .git/config <<\EOF
 819[section]
 820        ; comment \
 821        continued = cont\
 822inued
 823        noncont   = not continued ; \
 824        quotecont = "cont;\
 825inued"
 826EOF
 827
 828cat > expect <<\EOF
 829section.continued=continued
 830section.noncont=not continued
 831section.quotecont=cont;inued
 832EOF
 833
 834test_expect_success 'value continued on next line' '
 835        git config --list > result &&
 836        cmp result expect
 837'
 838
 839cat > .git/config <<\EOF
 840[section "sub=section"]
 841        val1 = foo=bar
 842        val2 = foo\nbar
 843        val3 = \n\n
 844        val4 =
 845        val5
 846EOF
 847
 848cat > expect <<\EOF
 849section.sub=section.val1
 850foo=barQsection.sub=section.val2
 851foo
 852barQsection.sub=section.val3
 853
 854
 855Qsection.sub=section.val4
 856Qsection.sub=section.val5Q
 857EOF
 858test_expect_success '--null --list' '
 859        git config --null --list | nul_to_q >result &&
 860        echo >>result &&
 861        test_cmp expect result
 862'
 863
 864test_expect_success '--null --get-regexp' '
 865        git config --null --get-regexp "val[0-9]" | nul_to_q >result &&
 866        echo >>result &&
 867        test_cmp expect result
 868'
 869
 870test_expect_success 'inner whitespace kept verbatim' '
 871        git config section.val "foo       bar" &&
 872        test "z$(git config section.val)" = "zfoo         bar"
 873'
 874
 875test_expect_success SYMLINKS 'symlinked configuration' '
 876
 877        ln -s notyet myconfig &&
 878        GIT_CONFIG=myconfig git config test.frotz nitfol &&
 879        test -h myconfig &&
 880        test -f notyet &&
 881        test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol &&
 882        GIT_CONFIG=myconfig git config test.xyzzy rezrov &&
 883        test -h myconfig &&
 884        test -f notyet &&
 885        test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol &&
 886        test "z$(GIT_CONFIG=notyet git config test.xyzzy)" = zrezrov
 887
 888'
 889
 890test_expect_success 'nonexistent configuration' '
 891        (
 892                GIT_CONFIG=doesnotexist &&
 893                export GIT_CONFIG &&
 894                test_must_fail git config --list &&
 895                test_must_fail git config test.xyzzy
 896        )
 897'
 898
 899test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
 900        ln -s doesnotexist linktonada &&
 901        ln -s linktonada linktolinktonada &&
 902        (
 903                GIT_CONFIG=linktonada &&
 904                export GIT_CONFIG &&
 905                test_must_fail git config --list &&
 906                GIT_CONFIG=linktolinktonada &&
 907                test_must_fail git config --list
 908        )
 909'
 910
 911test_expect_success 'check split_cmdline return' "
 912        git config alias.split-cmdline-fix 'echo \"' &&
 913        test_must_fail git split-cmdline-fix &&
 914        echo foo > foo &&
 915        git add foo &&
 916        git commit -m 'initial commit' &&
 917        git config branch.master.mergeoptions 'echo \"' &&
 918        test_must_fail git merge master
 919        "
 920
 921test_expect_success 'git -c "key=value" support' '
 922        test "z$(git -c core.name=value config core.name)" = zvalue &&
 923        test "z$(git -c foo.CamelCase=value config foo.camelcase)" = zvalue &&
 924        test "z$(git -c foo.flag config --bool foo.flag)" = ztrue &&
 925        test_must_fail git -c name=value config core.name
 926'
 927
 928test_expect_success 'key sanity-checking' '
 929        test_must_fail git config foo=bar &&
 930        test_must_fail git config foo=.bar &&
 931        test_must_fail git config foo.ba=r &&
 932        test_must_fail git config foo.1bar &&
 933        test_must_fail git config foo."ba
 934                                z".bar &&
 935        test_must_fail git config . false &&
 936        test_must_fail git config .foo false &&
 937        test_must_fail git config foo. false &&
 938        test_must_fail git config .foo. false &&
 939        git config foo.bar true &&
 940        git config foo."ba =z".bar false
 941'
 942
 943test_expect_success 'git -c works with aliases of builtins' '
 944        git config alias.checkconfig "-c foo.check=bar config foo.check" &&
 945        echo bar >expect &&
 946        git checkconfig >actual &&
 947        test_cmp expect actual
 948'
 949
 950test_expect_success 'git -c does not split values on equals' '
 951        echo "value with = in it" >expect &&
 952        git -c core.foo="value with = in it" config core.foo >actual &&
 953        test_cmp expect actual
 954'
 955
 956test_expect_success 'git -c dies on bogus config' '
 957        test_must_fail git -c core.bare=foo rev-parse
 958'
 959
 960test_expect_success 'git -c complains about empty key' '
 961        test_must_fail git -c "=foo" rev-parse
 962'
 963
 964test_expect_success 'git -c complains about empty key and value' '
 965        test_must_fail git -c "" rev-parse
 966'
 967
 968test_done