]> git.ipfire.org Git - thirdparty/git.git/blob - t/t1310-config-default.sh
The third batch
[thirdparty/git.git] / t / t1310-config-default.sh
1 #!/bin/sh
2
3 test_description='Test git config in different settings (with --default)'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'uses --default when entry missing' '
9 echo quux >expect &&
10 git config -f config --default=quux core.foo >actual &&
11 test_cmp expect actual
12 '
13
14 test_expect_success 'does not use --default when entry present' '
15 echo bar >expect &&
16 git -c core.foo=bar config --default=baz core.foo >actual &&
17 test_cmp expect actual
18 '
19
20 test_expect_success 'canonicalizes --default with appropriate type' '
21 echo true >expect &&
22 git config -f config --default=yes --bool core.foo >actual &&
23 test_cmp expect actual
24 '
25
26 test_expect_success 'dies when --default cannot be parsed' '
27 test_must_fail git config -f config --type=expiry-date --default=x --get \
28 not.a.section 2>error &&
29 test_grep "failed to format default config value" error
30 '
31
32 test_expect_success 'does not allow --default without --get' '
33 test_must_fail git config --default=quux --unset a.section >output 2>&1 &&
34 test_grep "\-\-default is only applicable to" output
35 '
36
37 test_done