interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t1311-config-optional.sh

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