Subject: [PATCH 1/2] format-patch: add a more exhaustive --range-diff test

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Thu, 22 Nov 2018 21:12:47 +0000

Change the narrow test added in 31e2617a5f ("format-patch: add
--range-diff option to embed diff in cover letter", 2018-07-22) to
test the full output. This test would have spotted a regression in the
output if it wasn't beating around the bush and tested the full
output, let's do that.

Signed-off-by: Ævar Arnfjörð Bjarmason <[email-masked]>
---
 t/t3206-range-diff.sh | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
index e497c1358f..0235c038be 100755
--- a/t/t3206-range-diff.sh
+++ b/t/t3206-range-diff.sh
@@ -249,11 +249,28 @@ for prev in topic master..topic
 do
 	test_expect_success "format-patch --range-diff=$prev" '
 		git format-patch --stdout --cover-letter --range-diff=$prev \
-			master..unmodified >actual &&
-		grep "= 1: .* s/5/A" actual &&
-		grep "= 2: .* s/4/A" actual &&
-		grep "= 3: .* s/11/B" actual &&
-		grep "= 4: .* s/12/B" actual
+			master..unmodified >actual.raw &&
+		sed -e "s|^:||" -e "s|:$||" >expect <<-\EOF &&
+		:1:  4de457d = 1:  35b9b25 s/5/A/
+		:     a => b | 0
+		:     1 file changed, 0 insertions(+), 0 deletions(-)
+		:    :
+		:2:  fccce22 = 2:  de345ab s/4/A/
+		:     a => b | 0
+		:     1 file changed, 0 insertions(+), 0 deletions(-)
+		:    :
+		:3:  147e64e = 3:  9af6654 s/11/B/
+		:     a => b | 0
+		:     1 file changed, 0 insertions(+), 0 deletions(-)
+		:    :
+		:4:  a63e992 = 4:  2901f77 s/12/B/
+		:     a => b | 0
+		:     1 file changed, 0 insertions(+), 0 deletions(-)
+		:    :
+		:-- :
+		EOF
+		sed -ne "/^1:/,/^--/p" <actual.raw >actual &&
+		test_cmp expect actual
 	'
 done
 
-- 
2.20.0.rc0.387.gc7a69e6b6c