aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-04 10:53:02 -0800
committerJunio C Hamano <gitster@pobox.com>2026-03-04 10:53:02 -0800
commita31d4f1860bf9ee594d3ee4dd0cdda90db6919cd (patch)
tree075112e892a6d1073d473949269d49c7ba435c24 /t
parentca1a1a75c185fc01ad858268b4431e835933e2eb (diff)
parent096aa6099834ce00401a369b34cbff4868ea5704 (diff)
downloadgit-a31d4f1860bf9ee594d3ee4dd0cdda90db6919cd.tar.xz
Merge branch 'ds/config-list-with-type'
"git config list" is taught to show the values interpreted for specific type with "--type=<X>" option. * ds/config-list-with-type: config: use an enum for type config: restructure format_config() config: format colors quietly color: add color_parse_quietly() config: format expiry dates quietly config: format paths gently config: format bools or strings in helper config: format bools or ints gently config: format bools gently config: format int64s gently config: make 'git config list --type=<X>' work config: add 'gently' parameter to format_config() config: move show_all_config()
Diffstat (limited to 't')
-rwxr-xr-xt/t1300-config.sh84
1 files changed, 83 insertions, 1 deletions
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 9850fcd5b5..128971ee12 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -2459,9 +2459,15 @@ done
cat >.git/config <<-\EOF &&
[section]
-foo = true
+foo = True
number = 10
big = 1M
+path = ~/dir
+red = red
+blue = Blue
+date = Fri Jun 4 15:46:55 2010
+missing=:(optional)no-such-path
+exists=:(optional)expect
EOF
test_expect_success 'identical modern --type specifiers are allowed' '
@@ -2503,6 +2509,82 @@ test_expect_success 'unset type specifiers may be reset to conflicting ones' '
test_cmp_config 1048576 --type=bool --no-type --type=int section.big
'
+test_expect_success 'list --type=int shows only canonicalizable int values' '
+ cat >expect <<-EOF &&
+ section.number=10
+ section.big=1048576
+ EOF
+
+ git config ${mode_prefix}list --type=int >actual 2>err &&
+ test_cmp expect actual &&
+ test_must_be_empty err
+'
+
+test_expect_success 'list --type=bool shows only canonicalizable bool values' '
+ cat >expect <<-EOF &&
+ section.foo=true
+ section.number=true
+ section.big=true
+ EOF
+
+ git config ${mode_prefix}list --type=bool >actual 2>err &&
+ test_cmp expect actual &&
+ test_must_be_empty err
+'
+
+test_expect_success 'list --type=bool-or-int shows only canonicalizable values' '
+ cat >expect <<-EOF &&
+ section.foo=true
+ section.number=10
+ section.big=1048576
+ EOF
+
+ git config ${mode_prefix}list --type=bool-or-int >actual 2>err &&
+ test_cmp expect actual &&
+ test_must_be_empty err
+'
+
+test_expect_success 'list --type=path shows only canonicalizable path values' '
+ cat >expect <<-EOF &&
+ section.foo=True
+ section.number=10
+ section.big=1M
+ section.path=$HOME/dir
+ section.red=red
+ section.blue=Blue
+ section.date=Fri Jun 4 15:46:55 2010
+ section.exists=expect
+ EOF
+
+ git config ${mode_prefix}list --type=path >actual 2>err &&
+ test_cmp expect actual &&
+ test_must_be_empty err
+'
+
+test_expect_success 'list --type=expiry-date shows only canonicalizable dates' '
+ git config ${mode_prefix}list --type=expiry-date >actual 2>err &&
+
+ # section.number and section.big parse as relative dates that could
+ # have clock skew in their results.
+ test_grep section.big actual &&
+ test_grep section.number actual &&
+ test_grep "section.date=$(git config --type=expiry-date section.$key)" actual &&
+ test_must_be_empty err
+'
+
+test_expect_success 'list --type=color shows only canonicalizable color values' '
+ cat >expect <<-EOF &&
+ section.number=<>
+ section.red=<RED>
+ section.blue=<BLUE>
+ EOF
+
+ git config ${mode_prefix}list --type=color >actual.raw 2>err &&
+ test_decode_color <actual.raw >actual &&
+ test_cmp expect actual &&
+ test_must_be_empty err
+'
+
test_expect_success '--type rejects unknown specifiers' '
test_must_fail git config --type=nonsense section.foo 2>error &&
test_grep "unrecognized --type argument" error