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

[PATCH] git-commit: fix cut_line behavior with CRLF

From
RGRobert Boyd III via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 11, 2023, 22:55 UTC
Message-ID
<pull.1513.git.1681253732794.gitgitgadget@gmail.com>
From: Robert Boyd III <git@robertboyd.dev>

On Windows with certain editor (mis)configurations, the cut_line that is used when commit.verbose is turned on doesn't work correctly because COMMIT_EDITMSG is rewritten with Windows line endings. This used to happen on old versions of VSCode, but I can't seem to reproduce it anymore without explicitly setting the line-endings to Windows. Even so, I think it would be sensible to fix this for good, even in the face of bad editor behavior.

This patch moves the \n ending out of the detection string constant, so that regardless of the line endings, the cut_line is detected correctly.

Signed-off-by: Robert Boyd III <git@robertboyd.dev>
---
    git-commit: fix cut_line behavior with CRLF
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1513%2Frob-3%2Fmaint-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1513/rob-3/maint-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1513
 wt-status.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 3162241a570..85904362fe5 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -24,7 +24,7 @@
 #define UF_DELAY_WARNING_IN_MS (2 * 1000)
 
 static const char cut_line[] =
-"------------------------ >8 ------------------------\n";
+"------------------------ >8 ------------------------";
 
 static char default_wt_status_colors[][COLOR_MAXLEN] = {
 	GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
@@ -1090,7 +1090,7 @@ void wt_status_append_cut_line(struct strbuf *buf)
 {
 	const char *explanation = _("Do not modify or remove the line above.\nEverything below it will be ignored.");
 
-	strbuf_commented_addf(buf, "%s", cut_line);
+	strbuf_commented_addf(buf, "%s\n", cut_line);
 	strbuf_add_commented_lines(buf, explanation, strlen(explanation));
 }
 

base-commit: 73876f4861cd3d187a4682290ab75c9dccadbc56
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 2 in “git-commit: fix cut_line behavior with CRLF”
  1. git-commit: fix cut_line behavior with CRLFRobert Boyd III via GitGitGadget, Apr 11, 2023
  2. Junio C HamanoApr 11, 2023

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.