From: Junio C Hamano Date: Wed, 29 Jun 2016 21:59:37 GMT Subject: Re: [PATCH 1/5] commit -C: skip blank lines at the beginning of the message Message-ID: In-Reply-To: <043eafd7ad4128d3a887c224ec6576d96872d1df.1467209576.git.johannes.schindelin@gmx.de> Johannes Schindelin writes: > Consistent with the pretty-printing machinery, we skip leading blank > lines (if any) of existing commit messages. > > While Git itself only produces commit objects with a single empty line > between commit header and commit message, it is legal to have more than > one blank line (i.e. lines containing only white space, or no > characters) at the beginning of the commit message, and the > pretty-printing code already handles that. > > Signed-off-by: Johannes Schindelin > --- > builtin/commit.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/builtin/commit.c b/builtin/commit.c > index 3f18942..1f6dbcd 100644 > --- a/builtin/commit.c > +++ b/builtin/commit.c > @@ -715,7 +715,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, > char *buffer; > buffer = strstr(use_message_buffer, "\n\n"); > if (buffer) > - strbuf_addstr(&sb, buffer + 2); > + strbuf_addstr(&sb, skip_blank_lines(buffer + 2)); > hook_arg1 = "commit"; > hook_arg2 = use_message; > } else if (fixup_message) { use_message_buffer is the contents of the commit object read elsewhere, and strstr() skips the header part, so this follows exactly the same pattern as the one you fixed earlier. Good.