]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t1300-config.sh
upload-pack: move allow_unadvertised_object_request to upload_pack_data
[thirdparty/git.git] / t / t1300-config.sh
index 9652b241c7cf182a4b26cac5f474183bd166ceaa..97ebfe1f9d5cea7b37d70d8f7069f00bb5045b8e 100755 (executable)
@@ -892,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 &&
@@ -1190,47 +1191,47 @@ 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
+       [V.A]
+       r = value1
        EOF
        q_to_tab >testConfig_expect <<-EOF &&
-               [V.A]
-               Qr = value2
+       [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
+       [V.A]
+       r = value1
        EOF
        q_to_tab >testConfig_expect <<-EOF &&
-               [V.A]
-               QR = value2
+       [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
+       [V.A]
+       r = value1
        EOF
        q_to_tab >testConfig_expect <<-EOF &&
-               [V.A]
-               r = value1
-               Qr = value2
+       [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
+       [V.A]
+       r = value1
        EOF
        q_to_tab >testConfig_expect <<-EOF &&
-               [V.A]
-               r = value1
-               Qr = value2
+       [V.A]
+       r = value1
+       Qr = value2
        EOF
        git config -f testConfig_actual "v.A.r" value2 &&
        test_cmp testConfig_expect testConfig_actual
@@ -1240,26 +1241,26 @@ 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
+       [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
+       [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 &&
@@ -1293,26 +1294,25 @@ test_expect_success 'git -c is not confused by empty environment' '
        GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
 '
 
-sq="'"
 test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
        cat >expect <<-\EOF &&
        env.one one
        env.two two
        EOF
-       GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq} ${sq}env.two=two${sq}" \
+       GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ} ${SQ}env.two=two${SQ}" \
                git config --get-regexp "env.*" >actual &&
        test_cmp expect actual &&
 
        cat >expect <<-EOF &&
-       env.one one${sq}
+       env.one one${SQ}
        env.two two
        EOF
-       GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq$sq$sq ${sq}env.two=two${sq}" \
+       GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ$SQ$SQ ${SQ}env.two=two${SQ}" \
                git config --get-regexp "env.*" >actual &&
        test_cmp expect actual &&
 
        test_must_fail env \
-               GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq ${sq}env.two=two${sq}" \
+               GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ ${SQ}env.two=two${SQ}" \
                git config --get-regexp "env.*"
 '
 
@@ -1408,6 +1408,8 @@ test_expect_success 'urlmatch favors more specific URLs' '
                cookieFile = /tmp/wildcard.txt
        [http "https://*.example.com/wildcardwithsubdomain"]
                cookieFile = /tmp/wildcardwithsubdomain.txt
+       [http "https://*.example.*"]
+               cookieFile = /tmp/multiwildcard.txt
        [http "https://trailing.example.com"]
                cookieFile = /tmp/trailing.txt
        [http "https://user@*.example.com/"]
@@ -1454,6 +1456,10 @@ test_expect_success 'urlmatch favors more specific URLs' '
 
        echo http.cookiefile /tmp/sub.txt >expect &&
        git config --get-urlmatch HTTP https://user@sub.example.com >actual &&
+       test_cmp expect actual &&
+
+       echo http.cookiefile /tmp/multiwildcard.txt >expect &&
+       git config --get-urlmatch HTTP https://wildcard.example.org >actual &&
        test_cmp expect actual
 '
 
@@ -1622,40 +1628,40 @@ test_expect_success 'set up --show-origin tests' '
        INCLUDE_DIR="$HOME/include" &&
        mkdir -p "$INCLUDE_DIR" &&
        cat >"$INCLUDE_DIR"/absolute.include <<-\EOF &&
-               [user]
-                       absolute = include
+       [user]
+               absolute = include
        EOF
        cat >"$INCLUDE_DIR"/relative.include <<-\EOF &&
-               [user]
-                       relative = include
+       [user]
+               relative = include
        EOF
        cat >"$HOME"/.gitconfig <<-EOF &&
-               [user]
-                       global = true
-                       override = global
-               [include]
-                       path = "$INCLUDE_DIR/absolute.include"
+       [user]
+               global = true
+               override = global
+       [include]
+               path = "$INCLUDE_DIR/absolute.include"
        EOF
        cat >.git/config <<-\EOF
-               [user]
-                       local = true
-                       override = local
-               [include]
-                       path = ../include/relative.include
+       [user]
+               local = true
+               override = local
+       [include]
+               path = ../include/relative.include
        EOF
 '
 
 test_expect_success '--show-origin with --list' '
        cat >expect <<-EOF &&
-               file:$HOME/.gitconfig   user.global=true
-               file:$HOME/.gitconfig   user.override=global
-               file:$HOME/.gitconfig   include.path=$INCLUDE_DIR/absolute.include
-               file:$INCLUDE_DIR/absolute.include      user.absolute=include
-               file:.git/config        user.local=true
-               file:.git/config        user.override=local
-               file:.git/config        include.path=../include/relative.include
-               file:.git/../include/relative.include   user.relative=include
-               command line:   user.cmdline=true
+       file:$HOME/.gitconfig   user.global=true
+       file:$HOME/.gitconfig   user.override=global
+       file:$HOME/.gitconfig   include.path=$INCLUDE_DIR/absolute.include
+       file:$INCLUDE_DIR/absolute.include      user.absolute=include
+       file:.git/config        user.local=true
+       file:.git/config        user.override=local
+       file:.git/config        include.path=../include/relative.include
+       file:.git/../include/relative.include   user.relative=include
+       command line:   user.cmdline=true
        EOF
        git -c user.cmdline=true config --list --show-origin >output &&
        test_cmp expect output
@@ -1663,16 +1669,16 @@ test_expect_success '--show-origin with --list' '
 
 test_expect_success '--show-origin with --list --null' '
        cat >expect <<-EOF &&
-               file:$HOME/.gitconfigQuser.global
-               trueQfile:$HOME/.gitconfigQuser.override
-               globalQfile:$HOME/.gitconfigQinclude.path
-               $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
-               includeQfile:.git/configQuser.local
-               trueQfile:.git/configQuser.override
-               localQfile:.git/configQinclude.path
-               ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
-               includeQcommand line:Quser.cmdline
-               trueQ
+       file:$HOME/.gitconfigQuser.global
+       trueQfile:$HOME/.gitconfigQuser.override
+       globalQfile:$HOME/.gitconfigQinclude.path
+       $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
+       includeQfile:.git/configQuser.local
+       trueQfile:.git/configQuser.override
+       localQfile:.git/configQinclude.path
+       ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
+       includeQcommand line:Quser.cmdline
+       trueQ
        EOF
        git -c user.cmdline=true config --null --list --show-origin >output.raw &&
        nul_to_q <output.raw >output &&
@@ -1684,9 +1690,9 @@ test_expect_success '--show-origin with --list --null' '
 
 test_expect_success '--show-origin with single file' '
        cat >expect <<-\EOF &&
-               file:.git/config        user.local=true
-               file:.git/config        user.override=local
-               file:.git/config        include.path=../include/relative.include
+       file:.git/config        user.local=true
+       file:.git/config        user.override=local
+       file:.git/config        include.path=../include/relative.include
        EOF
        git config --local --list --show-origin >output &&
        test_cmp expect output
@@ -1694,8 +1700,8 @@ test_expect_success '--show-origin with single file' '
 
 test_expect_success '--show-origin with --get-regexp' '
        cat >expect <<-EOF &&
-               file:$HOME/.gitconfig   user.global true
-               file:.git/config        user.local true
+       file:$HOME/.gitconfig   user.global true
+       file:.git/config        user.local true
        EOF
        git config --show-origin --get-regexp "user\.[g|l].*" >output &&
        test_cmp expect output
@@ -1703,31 +1709,36 @@ test_expect_success '--show-origin with --get-regexp' '
 
 test_expect_success '--show-origin getting a single key' '
        cat >expect <<-\EOF &&
-               file:.git/config        local
+       file:.git/config        local
        EOF
        git config --show-origin user.override >output &&
        test_cmp expect output
 '
 
 test_expect_success 'set up custom config file' '
-       CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" &&
+       CUSTOM_CONFIG_FILE="custom.conf" &&
        cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
-               [user]
-                       custom = true
+       [user]
+               custom = true
        EOF
 '
 
+test_expect_success !MINGW 'set up custom config file with special name characters' '
+       WEIRDLY_NAMED_FILE="file\" (dq) and spaces.conf" &&
+       cp "$CUSTOM_CONFIG_FILE" "$WEIRDLY_NAMED_FILE"
+'
+
 test_expect_success !MINGW '--show-origin escape special file name characters' '
        cat >expect <<-\EOF &&
-               file:"file\" (dq) and spaces.conf"      user.custom=true
+       file:"file\" (dq) and spaces.conf"      user.custom=true
        EOF
-       git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
+       git config --file "$WEIRDLY_NAMED_FILE" --show-origin --list >output &&
        test_cmp expect output
 '
 
 test_expect_success '--show-origin stdin' '
        cat >expect <<-\EOF &&
-               standard input: user.custom=true
+       standard input: user.custom=true
        EOF
        git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output &&
        test_cmp expect output
@@ -1735,11 +1746,11 @@ test_expect_success '--show-origin stdin' '
 
 test_expect_success '--show-origin stdin with file include' '
        cat >"$INCLUDE_DIR"/stdin.include <<-EOF &&
-               [user]
-                       stdin = include
+       [user]
+               stdin = include
        EOF
        cat >expect <<-EOF &&
-               file:$INCLUDE_DIR/stdin.include include
+       file:$INCLUDE_DIR/stdin.include include
        EOF
        echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
        git config --show-origin --includes --file - user.stdin >output &&
@@ -1747,18 +1758,18 @@ test_expect_success '--show-origin stdin with file include' '
        test_cmp expect output
 '
 
-test_expect_success !MINGW '--show-origin blob' '
+test_expect_success '--show-origin blob' '
        blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
        cat >expect <<-EOF &&
-               blob:$blob      user.custom=true
+       blob:$blob      user.custom=true
        EOF
        git config --blob=$blob --show-origin --list >output &&
        test_cmp expect output
 '
 
-test_expect_success !MINGW '--show-origin blob ref' '
+test_expect_success '--show-origin blob ref' '
        cat >expect <<-\EOF &&
-               blob:"master:file\" (dq) and spaces.conf"       user.custom=true
+       blob:master:custom.conf user.custom=true
        EOF
        git add "$CUSTOM_CONFIG_FILE" &&
        git commit -m "new config file" &&
@@ -1766,6 +1777,65 @@ test_expect_success !MINGW '--show-origin blob ref' '
        test_cmp expect output
 '
 
+test_expect_success '--show-scope with --list' '
+       cat >expect <<-EOF &&
+       global  user.global=true
+       global  user.override=global
+       global  include.path=$INCLUDE_DIR/absolute.include
+       global  user.absolute=include
+       local   user.local=true
+       local   user.override=local
+       local   include.path=../include/relative.include
+       local   user.relative=include
+       command user.cmdline=true
+       EOF
+       git -c user.cmdline=true config --list --show-scope >output &&
+       test_cmp expect output
+'
+
+test_expect_success !MINGW '--show-scope with --blob' '
+       blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
+       cat >expect <<-EOF &&
+       command user.custom=true
+       EOF
+       git config --blob=$blob --show-scope --list >output &&
+       test_cmp expect output
+'
+
+test_expect_success '--show-scope with --local' '
+       cat >expect <<-\EOF &&
+       local   user.local=true
+       local   user.override=local
+       local   include.path=../include/relative.include
+       EOF
+       git config --local --list --show-scope >output &&
+       test_cmp expect output
+'
+
+test_expect_success '--show-scope getting a single value' '
+       cat >expect <<-\EOF &&
+       local   true
+       EOF
+       git config --show-scope --get user.local >output &&
+       test_cmp expect output
+'
+
+test_expect_success '--show-scope with --show-origin' '
+       cat >expect <<-EOF &&
+       global  file:$HOME/.gitconfig   user.global=true
+       global  file:$HOME/.gitconfig   user.override=global
+       global  file:$HOME/.gitconfig   include.path=$INCLUDE_DIR/absolute.include
+       global  file:$INCLUDE_DIR/absolute.include      user.absolute=include
+       local   file:.git/config        user.local=true
+       local   file:.git/config        user.override=local
+       local   file:.git/config        include.path=../include/relative.include
+       local   file:.git/../include/relative.include   user.relative=include
+       command command line:   user.cmdline=true
+       EOF
+       git -c user.cmdline=true config --list --show-origin --show-scope >output &&
+       test_cmp expect output
+'
+
 test_expect_success '--local requires a repo' '
        # we expect 128 to ensure that we do not simply
        # fail to find anything and return code "1"