Subject: [RFC] Sample of test for git branch -vv

From: [email-masked]
Date: Fri, 1 Feb 2019 17:22:10 -0800

From: Nickolai Belakovski <[email-masked]>

I remember now why I didn't add a test for this one earlier.

Testing git branch -vv is a little tricky for a couple reasons.

For one thing, the output contains commit hashes, so the 'expect' file cannot be simply static.

For another, the output doesn't have clear delimiters for all columns, so trying to extract only
the commit hashes is tough.

I took the approach of stripping all information before and including the commit hashes.

You can see below how I did this. For the patch with worktreepath information, the worktreepath would
appear before the commit message on just one of those lines, but I crafted this patch so that it can be applied
to master.

This works, but it's rather awkward and ugly. Does anyone have better suggestions either for how to test or
how to implement?

---
 t/t3203-branch-output.sh | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index 94ab05ad59..b836ca21fa 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -285,4 +284,22 @@ test_expect_success '--color overrides auto-color' '
 	test_cmp expect.color actual
 '
 
+test_expect_success 'test verbose verbose output' '
+	cat >expect <<-EOF &&
+	one
+	one
+	two
+	one
+	two
+	two
+	two
+	EOF
+	git branch -vv >tmp &&
+	head -1 tmp >tmp2 &&
+	SUBSTRLENGTH=$(awk "{print index(\$0, \"one\")}" <tmp2) &&
+	awk -v len="$SUBSTRLENGTH" "{print substr(\$0,len,length(\$0))}" <tmp >actual &&
+	test_cmp expect actual
+'
+
+
 test_done
-- 
2.14.2