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

Re: [PATCH] commit: allow {--amend|-c foo} when {HEAD|foo} has empty message

From
Jeff King <peff@peff.net>
Date
Feb 28, 2012, 09:05 UTC
Message-ID
<20120228090540.GB5757@sigill.intra.peff.net>
In-Reply-To
<8529824c8569a8a0b4c4caf3a562750925758e74.1330419275.git.trast@student.ethz.ch>
On Tue, Feb 28, 2012 at 09:57:05AM +0100, Thomas Rast wrote:
Show 11 quoted lines
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 3714582..45a57af 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -690,7 +690,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  		hook_arg1 = "message";
>  	} else if (use_message) {
>  		buffer = strstr(use_message_buffer, "\n\n");
> -		if (!buffer || buffer[2] == '\0')
> +		if (!amend && !edit_message && (!buffer || buffer[2] == '\0'))
>  			die(_("commit has empty message"));

Hmm. So "buffer" used to never be NULL (because we would die if it is), and now we might not die if we are doing an amend, no? And the next line is:

>  		strbuf_add(&sb, buffer + 2, strlen(buffer + 2));

Doesn't this need to handle the case of NULL buffer (i.e., when it does not already have "\n\n" in it)?

-Peff
Previous: Thomas RastNext: Jeff King
Message 2 of 13 in “commit: allow {--amend|-c foo} when {HEAD|foo} has empty message”
  1. commit: allow {--amend|-c foo} when {HEAD|foo} has empty messageThomas Rast, Feb 28, 2012
  2. Jeff KingFeb 28, 2012
  3. Jeff KingFeb 28, 2012
  4. Thomas RastFeb 28, 2012
  5. Junio C HamanoFeb 28, 2012
  6. Jeff KingFeb 28, 2012
  7. Junio C HamanoFeb 28, 2012
  8. commit: allow {--amend|-c foo} when {HEAD|foo} has empty messageThomas Rast, Feb 28, 2012
  9. pretty: detect missing \n\n in commit messageThomas Rast, Feb 28, 2012
  10. Nguyen Thai Ngoc DuyFeb 28, 2012
  11. Junio C HamanoFeb 28, 2012
  12. parse_commit: refuse to load commit without \n\n separatorThomas Rast, Feb 28, 2012
  13. Junio C HamanoFeb 28, 2012

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.