From 84e213a30a1d4a3835e23b2f3d6217eb74ea55f7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 29 Jun 2016 16:14:42 +0200 Subject: commit -C: skip blank lines at the beginning of the message 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 Signed-off-by: Junio C Hamano --- builtin/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/commit.c b/builtin/commit.c index c2ebea4ed3..b0effbb929 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -712,7 +712,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) { -- cgit v1.2.1 From 054a5aee6f3e8e90d96f7b3f76f5f55752561c59 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 29 Jun 2016 16:14:50 +0200 Subject: reset --hard: skip blank lines when reporting the commit subject When there are blank lines at the beginning of a commit message, the pretty printing machinery already skips them when showing a commit subject (or the complete commit message). We shall henceforth do the same when reporting the commit subject after the user called git reset --hard Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin/reset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/reset.c b/builtin/reset.c index 4c08ddc1ca..34d8b236f1 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -103,7 +103,7 @@ static void print_new_head_line(struct commit *commit) if (body) { const char *eol; size_t len; - body += 2; + body = skip_blank_lines(body + 2); eol = strchr(body, '\n'); len = eol ? eol - body : strlen(body); printf(" %.*s\n", (int) len, body); -- cgit v1.2.1