builtin-commit: fix --signoff
The Signed-off-by: line contained a spurious timestamp. The reason was a call to git_committer_info(1), which automatically added the timestamp. Instead, fmt_ident() was taught to interpret an empty string for the date (as opposed to NULL, which still triggers the default behavior) as "do not bother with the timestamp", and builtin-commit.c uses it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
367c98866c
commit
13208572fb
@ -183,21 +183,29 @@ static int prepare_log_message(const char *index_file, const char *prefix)
|
||||
die("could not open %s\n", git_path(commit_editmsg));
|
||||
|
||||
stripspace(&sb, 0);
|
||||
|
||||
if (signoff) {
|
||||
struct strbuf sob;
|
||||
int i;
|
||||
|
||||
strbuf_init(&sob, 0);
|
||||
strbuf_addstr(&sob, sign_off_header);
|
||||
strbuf_addstr(&sob, fmt_ident(getenv("GIT_COMMITTER_NAME"),
|
||||
getenv("GIT_COMMITTER_EMAIL"),
|
||||
"", 1));
|
||||
strbuf_addch(&sob, '\n');
|
||||
|
||||
for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--)
|
||||
; /* do nothing */
|
||||
if (prefixcmp(sb.buf + i, sob.buf))
|
||||
strbuf_addbuf(&sb, &sob);
|
||||
strbuf_release(&sob);
|
||||
}
|
||||
|
||||
if (fwrite(sb.buf, 1, sb.len, fp) < sb.len)
|
||||
die("could not write commit template: %s\n",
|
||||
strerror(errno));
|
||||
|
||||
if (signoff) {
|
||||
const char *info, *bol;
|
||||
|
||||
info = git_committer_info(1);
|
||||
strbuf_addch(&sb, '\0');
|
||||
bol = strrchr(sb.buf + sb.len - 1, '\n');
|
||||
if (!bol || prefixcmp(bol, sign_off_header))
|
||||
fprintf(fp, "\n");
|
||||
fprintf(fp, "%s%s\n", sign_off_header, git_committer_info(1));
|
||||
}
|
||||
|
||||
strbuf_release(&sb);
|
||||
|
||||
if (in_merge && !no_edit)
|
||||
|
||||
Reference in New Issue
Block a user