From: Junio C Hamano Date: Tue, 28 Feb 2012 17:25:34 GMT Subject: Re: [PATCH v2] commit: allow {--amend|-c foo} when {HEAD|foo} has empty message Message-ID: <7vmx8227ld.fsf@alter.siamese.dyndns.org> In-Reply-To: <010901fbfffe0f806bb19d556ebc1e512a4697f4.1330425111.git.trast@student.ethz.ch> Thomas Rast writes: > 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.