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

git interpret-trailers: behavior with input without trailing newline

From
LWLuca Weiss <luca@z3ntu.xyz>
Date
Jul 8, 2021, 10:33 UTC
Message-ID
<CCNOOVFJVMLC.7L79PCH59K1C@arch-vps>
Hi all,
I'm investigating a behavior with git interpret-trailers where when the input does not end with a newline, git appends the trailer directly without a newline; and on running the same command again it doesn't detect the previous trailer anymore. 
I've whipped up a quick PoC in form of a new test case in the existing test cases of git.
Appending the patch here (sorry if it does get corrupted from my editor, but I hope you get the gist of it).
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index 04885d0a5e..602725f939 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -17,6 +17,7 @@ test_expect_success 'setup' '
 
 		body
 	EOF
+	printf "subject\n\nbody" > basic_message_no_eol &&
 	cat >complex_message_body <<-\EOF &&
 		my subject
 
@@ -676,6 +677,12 @@ test_expect_success 'with message that has an old style conflict block' '
 	test_cmp expected actual
 '
 
+test_expect_success 'bla blub' '
+	git interpret-trailers --trailer "Cc: Peff" basic_message_no_eol > intermediary &&
+	git interpret-trailers --trailer "Cc: Peff" intermediary > actual9 &&
+	test_cmp intermediary actual9
+'
+
 test_expect_success 'with commit complex message and trailer args' '
 	cat complex_message_body >expected &&
 	sed -e "s/ Z\$/ /" >>expected <<-\EOF &&


It doesn't feel like an expected behavior but if it is, please tell me.

Regards
Luca
Next: Jeff King
Message 1 of 2 in “git interpret-trailers: behavior with input without trailing newline”
  1. Luca WeissJul 8, 2021
  2. Jeff KingJul 13, 2021

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.