Skip to content

Commit 84e213a

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4e1b06d commit 84e213a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
712712
char *buffer;
713713
buffer = strstr(use_message_buffer, "\n\n");
714714
if (buffer)
715-
strbuf_addstr(&sb, buffer + 2);
715+
strbuf_addstr(&sb, skip_blank_lines(buffer + 2));
716716
hook_arg1 = "commit";
717717
hook_arg2 = use_message;
718718
} else if (fixup_message) {

0 commit comments

Comments
 (0)