]> git.ipfire.org Git - thirdparty/git.git/blob - t/t1307-config-blob.sh
Merge branch 'jc/fake-lstat'
[thirdparty/git.git] / t / t1307-config-blob.sh
1 #!/bin/sh
2
3 test_description='support for reading config from a blob'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_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
17 test_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
23 test_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
29 test_expect_success 'reading non-existing value from blob is an error' '
30 test_must_fail git config --blob=HEAD:config non.existing
31 '
32
33 test_expect_success 'reading from blob and file is an error' '
34 test_must_fail git config --blob=HEAD:config --system --list
35 '
36
37 test_expect_success 'reading from missing ref is an error' '
38 test_must_fail git config --blob=HEAD:doesnotexist --list
39 '
40
41 test_expect_success 'reading from non-blob is an error' '
42 test_must_fail git config --blob=HEAD --list
43 '
44
45 test_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
49 test_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
53 test_expect_success 'editing a blob is an error' '
54 test_must_fail git config --blob=HEAD:config --edit
55 '
56
57 test_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 &&
66 test_grep "HEAD:config" err
67 '
68
69 test_expect_success 'can parse blob ending with CR' '
70 test_commit --printf CR config "[some]key = value\\r" &&
71 echo value >expect &&
72 git config --blob=HEAD:config some.key >actual &&
73 test_cmp expect actual
74 '
75
76 test_expect_success 'config --blob outside of a repository is an error' '
77 nongit test_must_fail git config --blob=foo --list
78 '
79
80 test_done