3 test_description
='support for reading config from a blob'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'create config blob' '
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
23 test_expect_success
'fetch value from blob' '
25 git config --blob=HEAD:config --bool some.value >actual &&
26 test_cmp expect actual
29 test_expect_success
'reading non-existing value from blob is an error' '
30 test_must_fail git config --blob=HEAD:config non.existing
33 test_expect_success
'reading from blob and file is an error' '
34 test_must_fail git config --blob=HEAD:config --system --list
37 test_expect_success
'reading from missing ref is an error' '
38 test_must_fail git config --blob=HEAD:doesnotexist --list
41 test_expect_success
'reading from non-blob is an error' '
42 test_must_fail git config --blob=HEAD --list
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
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
53 test_expect_success
'editing a blob is an error' '
54 test_must_fail git config --blob=HEAD:config --edit
57 test_expect_success
'parse errors in blobs are properly attributed' '
58 cat >config <<-\EOF &&
63 git commit -m broken &&
65 test_must_fail git config --blob=HEAD:config some.value 2>err &&
66 test_grep "HEAD:config" err
69 test_expect_success
'can parse blob ending with CR' '
70 test_commit --printf CR config "[some]key = value\\r" &&
72 git config --blob=HEAD:config some.key >actual &&
73 test_cmp expect actual
76 test_expect_success
'config --blob outside of a repository is an error' '
77 nongit test_must_fail git config --blob=foo --list