submodule-config.c: use repo_get_oid for reading .gitmodules
[gitweb.git] / t / t1300-config.sh
index 03c223708ebb428125dffb4a9ca273629936ff0c..428177c390dbe726c2aa9df4eb9c6f9d54766049 100755 (executable)
@@ -76,15 +76,11 @@ EOF
 test_expect_success 'non-match result' 'test_cmp expect .git/config'
 
 test_expect_success 'find mixed-case key by canonical name' '
-       echo Second >expect &&
-       git config cores.whatever >actual &&
-       test_cmp expect actual
+       test_cmp_config Second cores.whatever
 '
 
 test_expect_success 'find mixed-case key by non-canonical name' '
-       echo Second >expect &&
-       git config CoReS.WhAtEvEr >actual &&
-       test_cmp expect actual
+       test_cmp_config Second CoReS.WhAtEvEr
 '
 
 test_expect_success 'subsections are not canonicalized by git-config' '
@@ -94,12 +90,8 @@ test_expect_success 'subsections are not canonicalized by git-config' '
        [section "SubSection"]
        key = two
        EOF
-       echo one >expect &&
-       git config section.subsection.key >actual &&
-       test_cmp expect actual &&
-       echo two >expect &&
-       git config section.SubSection.key >actual &&
-       test_cmp expect actual
+       test_cmp_config one section.subsection.key &&
+       test_cmp_config two section.SubSection.key
 '
 
 cat > .git/config <<\EOF
@@ -212,9 +204,7 @@ test_expect_success 'really really mean test' '
 '
 
 test_expect_success 'get value' '
-       echo alpha >expect &&
-       git config beta.haha >actual &&
-       test_cmp expect actual
+       test_cmp_config alpha beta.haha
 '
 
 cat > expect << EOF
@@ -251,15 +241,11 @@ test_expect_success 'non-match' '
 '
 
 test_expect_success 'non-match value' '
-       echo wow >expect &&
-       git config --get nextsection.nonewline !for >actual &&
-       test_cmp expect actual
+       test_cmp_config wow --get nextsection.nonewline !for
 '
 
 test_expect_success 'multi-valued get returns final one' '
-       echo "wow2 for me" >expect &&
-       git config --get nextsection.nonewline >actual &&
-       test_cmp expect actual
+       test_cmp_config "wow2 for me" --get nextsection.nonewline
 '
 
 test_expect_success 'multi-valued get-all returns all' '
@@ -346,12 +332,9 @@ test_expect_success 'working --list' '
        git config --list > output &&
        test_cmp expect output
 '
-cat > expect << EOF
-EOF
-
 test_expect_success '--list without repo produces empty output' '
        git --git-dir=nonexistent config --list >output &&
-       test_cmp expect output
+       test_must_be_empty output
 '
 
 cat > expect << EOF
@@ -523,21 +506,11 @@ test_expect_success 'editing stdin is an error' '
 
 test_expect_success 'refer config from subdirectory' '
        mkdir x &&
-       (
-               cd x &&
-               echo strasse >expect &&
-               git config --get --file ../other-config ein.bahn >actual &&
-               test_cmp expect actual
-       )
-
+       test_cmp_config -C x strasse --get --file ../other-config ein.bahn
 '
 
 test_expect_success 'refer config from subdirectory via --file' '
-       (
-               cd x &&
-               git config --file=../other-config --get ein.bahn >actual &&
-               test_cmp expect actual
-       )
+       test_cmp_config -C x strasse --file=../other-config --get ein.bahn
 '
 
 cat > expect << EOF
@@ -691,16 +664,13 @@ test_expect_success numbers '
 
 test_expect_success '--int is at least 64 bits' '
        git config giga.watts 121g &&
-       echo 129922760704 >expect &&
-       git config --int --get giga.watts >actual &&
-       test_cmp expect actual
+       echo  >expect &&
+       test_cmp_config 129922760704 --int --get giga.watts
 '
 
 test_expect_success 'invalid unit' '
        git config aninvalid.unit "1auto" &&
-       echo 1auto >expect &&
-       git config aninvalid.unit >actual &&
-       test_cmp expect actual &&
+       test_cmp_config 1auto aninvalid.unit &&
        test_must_fail git config --int --get aninvalid.unit 2>actual &&
        test_i18ngrep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual
 '
@@ -888,7 +858,7 @@ EOF
 
 test_expect_success !MINGW 'get --path copes with unset $HOME' '
        (
-               unset HOME;
+               sane_unset HOME &&
                test_must_fail git config --get --path path.home \
                        >result 2>msg &&
                git config --get --path path.normal >>result &&
@@ -922,6 +892,7 @@ test_expect_success 'get --expiry-date' '
        1510348087
        0
        EOF
+       : "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" &&
        {
                echo "$rel_out $(git config --expiry-date date.valid1)"
                git config --expiry-date date.valid2 &&
@@ -1004,7 +975,7 @@ EOF
 
 test_expect_success 'value continued on next line' '
        git config --list > result &&
-       test_cmp result expect
+       test_cmp expect result
 '
 
 cat > .git/config <<\EOF
@@ -1042,9 +1013,7 @@ test_expect_success '--null --get-regexp' '
 
 test_expect_success 'inner whitespace kept verbatim' '
        git config section.val "foo       bar" &&
-       echo "foo         bar" >expect &&
-       git config section.val >actual &&
-       test_cmp expect actual
+       test_cmp_config "foo      bar" section.val
 '
 
 test_expect_success SYMLINKS 'symlinked configuration' '
@@ -1218,6 +1187,93 @@ test_expect_success 'last one wins: three level vars' '
        test_cmp expect actual
 '
 
+test_expect_success 'old-fashioned settings are case insensitive' '
+       test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
+
+       cat >testConfig_actual <<-EOF &&
+               [V.A]
+               r = value1
+       EOF
+       q_to_tab >testConfig_expect <<-EOF &&
+               [V.A]
+               Qr = value2
+       EOF
+       git config -f testConfig_actual "v.a.r" value2 &&
+       test_cmp testConfig_expect testConfig_actual &&
+
+       cat >testConfig_actual <<-EOF &&
+               [V.A]
+               r = value1
+       EOF
+       q_to_tab >testConfig_expect <<-EOF &&
+               [V.A]
+               QR = value2
+       EOF
+       git config -f testConfig_actual "V.a.R" value2 &&
+       test_cmp testConfig_expect testConfig_actual &&
+
+       cat >testConfig_actual <<-EOF &&
+               [V.A]
+               r = value1
+       EOF
+       q_to_tab >testConfig_expect <<-EOF &&
+               [V.A]
+               r = value1
+               Qr = value2
+       EOF
+       git config -f testConfig_actual "V.A.r" value2 &&
+       test_cmp testConfig_expect testConfig_actual &&
+
+       cat >testConfig_actual <<-EOF &&
+               [V.A]
+               r = value1
+       EOF
+       q_to_tab >testConfig_expect <<-EOF &&
+               [V.A]
+               r = value1
+               Qr = value2
+       EOF
+       git config -f testConfig_actual "v.A.r" value2 &&
+       test_cmp testConfig_expect testConfig_actual
+'
+
+test_expect_success 'setting different case sensitive subsections ' '
+       test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
+
+       cat >testConfig_actual <<-EOF &&
+               [V "A"]
+               R = v1
+               [K "E"]
+               Y = v1
+               [a "b"]
+               c = v1
+               [d "e"]
+               f = v1
+       EOF
+       q_to_tab >testConfig_expect <<-EOF &&
+               [V "A"]
+               Qr = v2
+               [K "E"]
+               Qy = v2
+               [a "b"]
+               Qc = v2
+               [d "e"]
+               f = v1
+               [d "E"]
+               Qf = v2
+       EOF
+       # exact match
+       git config -f testConfig_actual a.b.c v2 &&
+       # match section and subsection, key is cased differently.
+       git config -f testConfig_actual K.E.y v2 &&
+       # section and key are matched case insensitive, but subsection needs
+       # to match; When writing out new values only the key is adjusted
+       git config -f testConfig_actual v.A.r v2 &&
+       # subsection is not matched:
+       git config -f testConfig_actual d.E.f v2 &&
+       test_cmp testConfig_expect testConfig_actual
+'
+
 for VAR in a .a a. a.0b a."b c". a."b c".0d
 do
        test_expect_success "git -c $VAR=VAL rejects invalid '$VAR'" '
@@ -1686,8 +1742,9 @@ test_expect_success '--show-origin stdin with file include' '
        cat >expect <<-EOF &&
                file:$INCLUDE_DIR/stdin.include include
        EOF
-       echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
-               | git config --show-origin --includes --file - user.stdin >output &&
+       echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
+       git config --show-origin --includes --file - user.stdin >output &&
+
        test_cmp expect output
 '
 
@@ -1724,21 +1781,15 @@ big = 1M
 EOF
 
 test_expect_success 'identical modern --type specifiers are allowed' '
-       git config --type=int --type=int core.big >actual &&
-       echo 1048576 >expect &&
-       test_cmp expect actual
+       test_cmp_config 1048576 --type=int --type=int core.big
 '
 
 test_expect_success 'identical legacy --type specifiers are allowed' '
-       git config --int --int core.big >actual &&
-       echo 1048576 >expect &&
-       test_cmp expect actual
+       test_cmp_config 1048576 --int --int core.big
 '
 
 test_expect_success 'identical mixed --type specifiers are allowed' '
-       git config --int --type=int core.big >actual &&
-       echo 1048576 >expect &&
-       test_cmp expect actual
+       test_cmp_config 1048576 --int --type=int core.big
 '
 
 test_expect_success 'non-identical modern --type specifiers are not allowed' '
@@ -1757,21 +1808,15 @@ test_expect_success 'non-identical mixed --type specifiers are not allowed' '
 '
 
 test_expect_success '--type allows valid type specifiers' '
-       echo "true" >expect &&
-       git config --type=bool core.foo >actual &&
-       test_cmp expect actual
+       test_cmp_config true  --type=bool core.foo
 '
 
 test_expect_success '--no-type unsets type specifiers' '
-       echo "10" >expect &&
-       git config --type=bool --no-type core.number >actual &&
-       test_cmp expect actual
+       test_cmp_config 10 --type=bool --no-type core.number
 '
 
 test_expect_success 'unset type specifiers may be reset to conflicting ones' '
-       echo 1048576 >expect &&
-       git config --type=bool --no-type --type=int core.big >actual &&
-       test_cmp expect actual
+       test_cmp_config 1048576 --type=bool --no-type --type=int core.big
 '
 
 test_expect_success '--type rejects unknown specifiers' '
@@ -1797,7 +1842,7 @@ test_expect_success '--replace-all does not invent newlines' '
        Qkey = b
        EOF
        git config --replace-all abc.key b &&
-       test_cmp .git/config expect
+       test_cmp expect .git/config
 '
 
 test_done