提交 16b0bb99 编写于 作者: J Jeff King 提交者: Junio C Hamano

am: fix broken email with --committer-date-is-author-date

Commit e8cbe211 (am: stop exporting GIT_COMMITTER_DATE, 2020-08-17)
rewrote the code for setting the committer date to use fmt_ident(),
rather than setting an environment variable and letting commit_tree()
handle it. But it introduced two bugs:

  - we use the author email string instead of the committer email

  - when parsing the committer ident, we used the wrong variable to
    compute the length of the email, resulting in it always being a
    zero-length string

This commit fixes both, which causes our test of this option via the
rebase "apply" backend to now succeed.
Signed-off-by: NJeff King <peff@peff.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 56706dba
...@@ -161,7 +161,7 @@ static void am_state_init(struct am_state *state) ...@@ -161,7 +161,7 @@ static void am_state_init(struct am_state *state)
state->committer_name = state->committer_name =
xmemdupz(id.name_begin, id.name_end - id.name_begin); xmemdupz(id.name_begin, id.name_end - id.name_begin);
state->committer_email = state->committer_email =
xmemdupz(id.mail_begin, id.mail_end - id.mail_end); xmemdupz(id.mail_begin, id.mail_end - id.mail_begin);
} }
/** /**
...@@ -1595,7 +1595,7 @@ static void do_commit(const struct am_state *state) ...@@ -1595,7 +1595,7 @@ static void do_commit(const struct am_state *state)
if (state->committer_date_is_author_date) if (state->committer_date_is_author_date)
committer = fmt_ident(state->committer_name, committer = fmt_ident(state->committer_name,
state->author_email, WANT_COMMITTER_IDENT, state->committer_email, WANT_COMMITTER_IDENT,
state->ignore_date ? NULL state->ignore_date ? NULL
: state->author_date, : state->author_date,
IDENT_STRICT); IDENT_STRICT);
......
...@@ -70,7 +70,7 @@ test_ctime_is_atime () { ...@@ -70,7 +70,7 @@ test_ctime_is_atime () {
test_cmp authortime committertime test_cmp authortime committertime
} }
test_expect_failure '--committer-date-is-author-date works with apply backend' ' test_expect_success '--committer-date-is-author-date works with apply backend' '
GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author && GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author &&
git rebase --apply --committer-date-is-author-date HEAD^ && git rebase --apply --committer-date-is-author-date HEAD^ &&
test_ctime_is_atime -1 test_ctime_is_atime -1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册