]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1310-config-default.sh
The third batch
[thirdparty/git.git] / t / t1310-config-default.sh
CommitLineData
eeaa24b9
TB
1#!/bin/sh
2
3test_description='Test git config in different settings (with --default)'
4
67606301 5TEST_PASSES_SANITIZE_LEAK=true
eeaa24b9
TB
6. ./test-lib.sh
7
8test_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
14test_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
20test_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
26test_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 &&
6789275d 29 test_grep "failed to format default config value" error
eeaa24b9
TB
30'
31
32test_expect_success 'does not allow --default without --get' '
33 test_must_fail git config --default=quux --unset a.section >output 2>&1 &&
6789275d 34 test_grep "\-\-default is only applicable to" output
eeaa24b9
TB
35'
36
37test_done