diff mbox series

[v2,5/8] branch tests: assert lookup_commit_reference_gently() error

Message ID patch-5.8-8982c42127-20210420T133218Z-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series object.c: add and use "is expected" utility function + object_as_type() use | expand

Commit Message

Ævar Arnfjörð Bjarmason April 20, 2021, 1:36 p.m. UTC
Assert the exact error returned by lookup_commit_reference_gently()
and "branch' itself in the non-quiet mode invoked by branch.c (via
parse_opt_commits()). This will be used to assert a subsequent change
that changes the lookup_commit_reference_gently() code.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t3201-branch-contains.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh
index 349a810cee..5bd4b05b6e 100755
--- a/t/t3201-branch-contains.sh
+++ b/t/t3201-branch-contains.sh
@@ -166,7 +166,13 @@  test_expect_success 'implicit --list conflicts with modification options' '
 '
 
 test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
-	test_must_fail git branch --contains main^{tree} &&
+	tree=$(git rev-parse main^{tree}) &&
+	test_must_fail git branch --contains main^{tree} 2>actual &&
+	cat >expect <<-EOF &&
+	error: object $tree is a tree, not a commit
+	error: no such commit main^{tree}
+	EOF
+	test_cmp expect actual &&
 	blob=$(git hash-object -w --stdin <<-\EOF
 	Some blob
 	EOF