blob: fbbacfc67b368d1e85ef3614dad05896d3088c97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/sh
#
# Copyright (c) 2025 Google LLC
#
test_description=':(optional) paths'
. ./test-lib.sh
test_expect_success 'var=:(optional)path-exists' '
test_config a.path ":(optional)path-exists" &&
>path-exists &&
echo path-exists >expect &&
git config get --path a.path >actual &&
test_cmp expect actual
'
test_expect_success 'missing optional value is ignored' '
test_config a.path ":(optional)no-such-path" &&
# Using --show-scope ensures we skip writing not only the value
# but also any meta-information about the ignored key.
test_must_fail git config get --show-scope --path a.path >actual &&
test_line_count = 0 actual
'
test_expect_success 'missing optional value is ignored in multi-value config' '
test_when_finished "git config unset --all a.path" &&
git config set --append a.path ":(optional)path-exists" &&
git config set --append a.path ":(optional)no-such-path" &&
>path-exists &&
echo path-exists >expect &&
git config --get --path a.path >actual &&
test_cmp expect actual
'
test_done
|