Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t1307-config-blob.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t1307-config-blob.sh` 100 lines ยท 2726 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='support for reading config from a blob' 4 5 . ./test-lib.sh 6 7 test_expect_success 'create config blob' ' 8 cat >config <<-\EOF && 9 [some] 10 value = 1 11 EOF 12 git add config && 13 git commit -m foo 14 ' 15 16 test_expect_success 'list config blob contents' ' 17 echo some.value=1 >expect && 18 git config --blob=HEAD:config --list >actual && 19 test_cmp expect actual 20 ' 21 22 test_expect_success 'fetch value from blob' ' 23 echo true >expect && 24 git config --blob=HEAD:config --bool some.value >actual && 25 test_cmp expect actual 26 ' 27 28 test_expect_success 'reading non-existing value from blob is an error' ' 29 test_must_fail git config --blob=HEAD:config non.existing 30 ' 31 32 test_expect_success 'reading from blob and file is an error' ' 33 test_must_fail git config --blob=HEAD:config --system --list 34 ' 35 36 test_expect_success 'reading from missing ref is an error' ' 37 test_must_fail git config --blob=HEAD:doesnotexist --list 38 ' 39 40 test_expect_success 'reading from non-blob is an error' ' 41 test_must_fail git config --blob=HEAD --list 42 ' 43 44 test_expect_success 'setting a value in a blob is an error' ' 45 test_must_fail git config --blob=HEAD:config some.value foo 46 ' 47 48 test_expect_success 'deleting a value in a blob is an error' ' 49 test_must_fail git config --blob=HEAD:config --unset some.value 50 ' 51 52 test_expect_success 'editing a blob is an error' ' 53 test_must_fail git config --blob=HEAD:config --edit 54 ' 55 56 test_expect_success 'parse errors in blobs are properly attributed' ' 57 cat >config <<-\EOF && 58 [some] 59 value = " 60 EOF 61 git add config && 62 git commit -m broken && 63 64 test_must_fail git config --blob=HEAD:config some.value 2>err && 65 test_grep "HEAD:config" err 66 ' 67 68 test_expect_success 'can parse blob ending with CR' ' 69 test_commit --printf CR config "[some]key = value\\r" && 70 echo value >expect && 71 git config --blob=HEAD:config some.key >actual && 72 test_cmp expect actual 73 ' 74 75 test_expect_success 'a byte 0xff does not end a blob' ' 76 test_commit --printf FF config "# caf\\377\\n[some]\\n\\tkey = value\\n" && 77 echo value >expect && 78 git config --blob=HEAD:config some.key >actual && 79 test_cmp expect actual 80 ' 81 82 test_expect_success 'a byte 0xff after a CR in a blob' ' 83 test_commit --printf CRFF config "# a\\r\\377\\n[some]\\n\\tkey = value\\n" && 84 echo value >expect && 85 git config --blob=HEAD:config some.key >actual && 86 test_cmp expect actual 87 ' 88 89 test_expect_success 'can parse blob starting with a byte order mark' ' 90 test_commit --printf BOM config "\\357\\273\\277[some]\\n\\tkey = value\\n" && 91 echo value >expect && 92 git config --blob=HEAD:config some.key >actual && 93 test_cmp expect actual 94 ' 95 96 test_expect_success 'config --blob outside of a repository is an error' ' 97 nongit test_must_fail git config --blob=foo --list 98 ' 99 100 test_done