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