]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1307-config-blob.sh
The third batch
[thirdparty/git.git] / t / t1307-config-blob.sh
CommitLineData
1bc88819
HV
1#!/bin/sh
2
3test_description='support for reading config from a blob'
67606301
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
1bc88819
HV
6. ./test-lib.sh
7
8test_expect_success 'create config blob' '
9 cat >config <<-\EOF &&
10 [some]
11 value = 1
12 EOF
13 git add config &&
14 git commit -m foo
15'
16
17test_expect_success 'list config blob contents' '
18 echo some.value=1 >expect &&
19 git config --blob=HEAD:config --list >actual &&
20 test_cmp expect actual
21'
22
23test_expect_success 'fetch value from blob' '
24 echo true >expect &&
25 git config --blob=HEAD:config --bool some.value >actual &&
26 test_cmp expect actual
27'
28
29test_expect_success 'reading non-existing value from blob is an error' '
30 test_must_fail git config --blob=HEAD:config non.existing
31'
32
33test_expect_success 'reading from blob and file is an error' '
34 test_must_fail git config --blob=HEAD:config --system --list
35'
36
37test_expect_success 'reading from missing ref is an error' '
38 test_must_fail git config --blob=HEAD:doesnotexist --list
39'
40
41test_expect_success 'reading from non-blob is an error' '
42 test_must_fail git config --blob=HEAD --list
43'
44
45test_expect_success 'setting a value in a blob is an error' '
46 test_must_fail git config --blob=HEAD:config some.value foo
47'
48
49test_expect_success 'deleting a value in a blob is an error' '
50 test_must_fail git config --blob=HEAD:config --unset some.value
51'
52
53test_expect_success 'editing a blob is an error' '
54 test_must_fail git config --blob=HEAD:config --edit
55'
56
57test_expect_success 'parse errors in blobs are properly attributed' '
58 cat >config <<-\EOF &&
59 [some]
60 value = "
61 EOF
62 git add config &&
63 git commit -m broken &&
64
65 test_must_fail git config --blob=HEAD:config some.value 2>err &&
6789275d 66 test_grep "HEAD:config" err
1bc88819
HV
67'
68
5e0be134 69test_expect_success 'can parse blob ending with CR' '
47c88d16 70 test_commit --printf CR config "[some]key = value\\r" &&
5e0be134
JK
71 echo value >expect &&
72 git config --blob=HEAD:config some.key >actual &&
73 test_cmp expect actual
74'
75
17b8a2d6 76test_expect_success 'config --blob outside of a repository is an error' '
9b92070e 77 nongit test_must_fail git config --blob=foo --list
17b8a2d6
JK
78'
79
1bc88819 80test_done