Merge branch 'jc/exclusion-doc'
[alt-git.git] / t / t1307-config-blob.sh
blob3c6791e6be705bc823ff180cd481fef3dc939734
1 #!/bin/sh
3 test_description='support for reading config from a blob'
4 . ./test-lib.sh
6 test_expect_success 'create config blob' '
7 cat >config <<-\EOF &&
8 [some]
9 value = 1
10 EOF
11 git add config &&
12 git commit -m foo
15 test_expect_success 'list config blob contents' '
16 echo some.value=1 >expect &&
17 git config --blob=HEAD:config --list >actual &&
18 test_cmp expect actual
21 test_expect_success 'fetch value from blob' '
22 echo true >expect &&
23 git config --blob=HEAD:config --bool some.value >actual &&
24 test_cmp expect actual
27 test_expect_success 'reading non-existing value from blob is an error' '
28 test_must_fail git config --blob=HEAD:config non.existing
31 test_expect_success 'reading from blob and file is an error' '
32 test_must_fail git config --blob=HEAD:config --system --list
35 test_expect_success 'reading from missing ref is an error' '
36 test_must_fail git config --blob=HEAD:doesnotexist --list
39 test_expect_success 'reading from non-blob is an error' '
40 test_must_fail git config --blob=HEAD --list
43 test_expect_success 'setting a value in a blob is an error' '
44 test_must_fail git config --blob=HEAD:config some.value foo
47 test_expect_success 'deleting a value in a blob is an error' '
48 test_must_fail git config --blob=HEAD:config --unset some.value
51 test_expect_success 'editing a blob is an error' '
52 test_must_fail git config --blob=HEAD:config --edit
55 test_expect_success 'parse errors in blobs are properly attributed' '
56 cat >config <<-\EOF &&
57 [some]
58 value = "
59 EOF
60 git add config &&
61 git commit -m broken &&
63 test_must_fail git config --blob=HEAD:config some.value 2>err &&
65 # just grep for our token as the exact error message is likely to
66 # change or be internationalized
67 grep "HEAD:config" err
70 test_expect_success 'can parse blob ending with CR' '
71 printf "[some]key = value\\r" >config &&
72 git add config &&
73 git commit -m CR &&
74 echo value >expect &&
75 git config --blob=HEAD:config some.key >actual &&
76 test_cmp expect actual
79 test_done