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

[PATCH] commit: don't use-editor when allow-empty-message

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
May 27, 2013, 14:03 UTC
Message-ID
<1369663431-2405-1-git-send-email-artagnon@gmail.com>
In-Reply-To
<195A1F16-B587-4217-97BF-6A92DA8C0786@gmail.com>

Commit a24a41e (git-commit: only append a newline to -m mesg if necessary, 2013-02-18) introduced a regression: when --allow-empty-message is used and an empty message is explicitly specified with -m "", git commit still launches $EDITOR unnecessarily. The commit (correctly) fixes opt_parse_m() to not fill in two newlines into the message buffer unconditionally. The real problem is that launching $EDITOR only depends on use_editor and whether message is empty. Fix the problem by setting use_editor to 0 when --allow-empty-message is specified in the codepath where an explicit string is passed via -m.

Reported-by: Mislav Marohnić <mislav.marohnic@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 builtin/commit.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/builtin/commit.c b/builtin/commit.c
index d2f30d9..1f5da9d 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -128,6 +128,8 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)
 			strbuf_addch(buf, '\n');
 		strbuf_addstr(buf, arg);
 		strbuf_complete_line(buf);
+		if (allow_empty_message)
+			use_editor = 0;
 	}
 	return 0;
 }
-- 
1.8.3.1.g33669de
Previous: René ScharfeNext: Ramkumar Ramachandra
Message 3 of 7 in “Commit with an empty message broken since v1.8.2.1”
  1. Mislav MarohnićMay 25, 2013
  2. commit: don't start editor if empty message is given with -mRené Scharfe, May 25, 2013
  3. commit: don't use-editor when allow-empty-messageRamkumar Ramachandra, May 27, 2013
  4. Ramkumar RamachandraMay 27, 2013
  5. commit: don't use-editor when allow-empty-messageRamkumar Ramachandra, May 27, 2013
  6. Antoine PelisseMay 27, 2013
  7. Ramkumar RamachandraMay 27, 2013

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.