git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] trailer: add tests for trailer.trimEmpty

From
Christian Couder <chriscool@tuxfamily.org>
Date
Feb 7, 2015, 13:11 UTC
Message-ID
<20150207131112.394.64847.chriscool@tuxfamily.org>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/t7513-interpret-trailers.sh | 72 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index bd0ab46..066d00b 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -892,4 +892,76 @@ test_expect_success 'with no command and no key' '
 	test_cmp expected actual
 '
 
+test_expect_success 'with trailer.trimEmpty set to true' '
+	git config trailer.trimEmpty true &&
+	cat >expected <<-EOF &&
+
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --trailer "review:" \
+		--trailer "Thanks-to:Johannes" >actual <<-EOF
+	EOF
+	test_cmp expected actual
+'
+
+test_expect_success 'with trailer.trimEmpty set to false' '
+	git config trailer.trimEmpty false &&
+	sed -e "s/ Z\$/ /" >expected <<-EOF &&
+
+		review: Z
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --trailer "review:" \
+		--trailer "Thanks-to:Johannes" >actual <<-EOF
+	EOF
+	test_cmp expected actual
+'
+
+test_expect_success 'with trailer.trimEmpty set to false and a message' '
+	cat complex_message_body >expected &&
+	sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+		Fixes: Z
+		Acked-by= Z
+		Reviewed-by: Z
+		Signed-off-by: Z
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --trailer "review:" \
+		--trailer "Thanks-to:Johannes" complex_message >actual
+	test_cmp expected actual &&
+	git interpret-trailers --no-trim-empty --trailer "review:" \
+		--trailer "Thanks-to:Johannes" complex_message >actual
+	test_cmp expected actual
+'
+
+test_expect_success 'with trailer.trimEmpty set to 1 and a message' '
+	git config trailer.trimEmpty 1 &&
+	cat complex_message_body >expected &&
+	sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --trailer "review:" \
+		--trailer "Thanks-to:Johannes" complex_message >actual
+	test_cmp expected actual
+'
+
+test_expect_success 'with trailer.trimEmpty set to 1 and --no-trim-empty' '
+	cat complex_message_body >expected &&
+	sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+		Fixes: Z
+		Acked-by= Z
+		Reviewed-by: Z
+		Signed-off-by: Z
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --no-trim-empty --trailer "review:" \
+		--trailer "Thanks-to:Johannes" complex_message >actual
+	test_cmp expected actual
+'
+
 test_done
-- 
2.2.1.313.gcc831f2
Message 1 of 1 in “trailer: add tests for trailer.trimEmpty”
  1. 2/3 trailer: add tests for trailer.trimEmptyChristian Couder, Feb 7, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.