@matheusbsbs / matheus-bagliano / commits / 2150554b0e
Fork 0

builtin-commit --s: add a newline if the last line was not a S-o-b

The rule is this: if the last line already contains the sign off by the current committer, do nothing. If it contains another sign off, just add the sign off of the current committer. If the last line does not contain a sign off, add a new line before adding the sign off. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Nov 11, 2007 at 17:36 UTC 2150554b0ed60356d8918b610834c04ad2eecdec
2 files changed +5 -1
builtin-commit.c
+4 -1
@@ -197,8 +197,11 @@ static int prepare_log_message(const char *index_file, const char *prefix)
197
198 for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--)
199 ; /* do nothing */
200 - if (prefixcmp(sb.buf + i, sob.buf))
200 + if (prefixcmp(sb.buf + i, sob.buf)) {
201 + if (prefixcmp(sb.buf + i, sign_off_header))
202 + strbuf_addch(&sb, '\n');
203 strbuf_addbuf(&sb, &sob);
204 + }
205 strbuf_release(&sob);
206 }
207
t/t7500-commit.sh
+1
@@ -126,6 +126,7 @@ test_expect_success 'using alternate GIT_INDEX_FILE (2)' '
126
127 cat > expect << EOF
128 zort
129 +
130 Signed-off-by: C O Mitter <committer@example.com>
131 EOF
132