Skip to content

Commit

Permalink
builtin-commit --s: add a newline if the last line was not a S-o-b
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Nov 23, 2007
1 parent 1320857 commit 2150554
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ static int prepare_log_message(const char *index_file, const char *prefix)

for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--)
; /* do nothing */
if (prefixcmp(sb.buf + i, sob.buf))
if (prefixcmp(sb.buf + i, sob.buf)) {
if (prefixcmp(sb.buf + i, sign_off_header))
strbuf_addch(&sb, '\n');
strbuf_addbuf(&sb, &sob);
}
strbuf_release(&sob);
}

Expand Down
1 change: 1 addition & 0 deletions t/t7500-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ test_expect_success 'using alternate GIT_INDEX_FILE (2)' '

cat > expect << EOF
zort
Signed-off-by: C O Mitter <committer@example.com>
EOF

Expand Down

0 comments on commit 2150554

Please sign in to comment.