Skip to content

Commit 68c69f9

Browse files
avargitster
authored andcommitted
cat-file tests: test messaging on bad objects/paths
Add tests for the output that's emitted when we disambiguate <obj>:<path> in cat-file. This gives us a baseline for improving these messages. For e.g. "git blame" we'll emit: $ git blame HEAD:foo fatal: no such path 'HEAD:foo' in HEAD But cat-file doesn't disambiguate these two cases, and just gives the rather unhelpful: $ git cat-file --textconv HEAD:foo fatal: Not a valid object name HEAD:foo Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ddf8420 commit 68c69f9

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

t/t8007-cat-file-textconv.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,48 @@ test_expect_success 'setup ' '
1919
GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
2020
'
2121

22+
test_expect_success 'usage: <bad rev>' '
23+
cat >expect <<-\EOF &&
24+
fatal: Not a valid object name HEAD2
25+
EOF
26+
test_must_fail git cat-file --textconv HEAD2 2>actual &&
27+
test_cmp expect actual
28+
'
29+
30+
test_expect_success 'usage: <bad rev>:<bad path>' '
31+
cat >expect <<-\EOF &&
32+
fatal: Not a valid object name HEAD2:two.bin
33+
EOF
34+
test_must_fail git cat-file --textconv HEAD2:two.bin 2>actual &&
35+
test_cmp expect actual
36+
'
37+
38+
test_expect_success 'usage: <rev>:<bad path>' '
39+
cat >expect <<-\EOF &&
40+
fatal: Not a valid object name HEAD:two.bin
41+
EOF
42+
test_must_fail git cat-file --textconv HEAD:two.bin 2>actual &&
43+
test_cmp expect actual
44+
'
45+
46+
47+
test_expect_success 'usage: <rev> with no <path>' '
48+
cat >expect <<-\EOF &&
49+
fatal: git cat-file --textconv HEAD: <object> must be <sha1:path>
50+
EOF
51+
test_must_fail git cat-file --textconv HEAD 2>actual &&
52+
test_cmp expect actual
53+
'
54+
55+
56+
test_expect_success 'usage: <bad rev>:<good (in HEAD) path>' '
57+
cat >expect <<-\EOF &&
58+
fatal: Not a valid object name HEAD2:one.bin
59+
EOF
60+
test_must_fail git cat-file --textconv HEAD2:one.bin 2>actual &&
61+
test_cmp expect actual
62+
'
63+
2264
cat >expected <<EOF
2365
bin: test version 2
2466
EOF

0 commit comments

Comments
 (0)