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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 28, 2012, 17:25 UTC
Message-ID
<7vmx8227ld.fsf@alter.siamese.dyndns.org>
In-Reply-To
<010901fbfffe0f806bb19d556ebc1e512a4697f4.1330425111.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 11 quoted lines
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 3714582..5e9a832 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -690,7 +690,9 @@ 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 (!buffer)
> +			die(_("commit object has invalid format"));
In line with my previous comment, I think this should be more like:
	if (!buffer) {
		static char v_o_i_d[] = "\n\n";
        	buffer = v_o_i_d;
                warning(_("commit lacks end-of-header. A broken Git emulation?"");
	}
The warning is of course optional.
Previous: Thomas Rast
Message 13 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.