Skip to content

Commit 16b0bb9

Browse files
peffgitster
authored andcommitted
am: fix broken email with --committer-date-is-author-date
Commit e8cbe21 (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: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 56706db commit 16b0bb9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builtin/am.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static void am_state_init(struct am_state *state)
161161
state->committer_name =
162162
xmemdupz(id.name_begin, id.name_end - id.name_begin);
163163
state->committer_email =
164-
xmemdupz(id.mail_begin, id.mail_end - id.mail_end);
164+
xmemdupz(id.mail_begin, id.mail_end - id.mail_begin);
165165
}
166166

167167
/**
@@ -1595,7 +1595,7 @@ static void do_commit(const struct am_state *state)
15951595

15961596
if (state->committer_date_is_author_date)
15971597
committer = fmt_ident(state->committer_name,
1598-
state->author_email, WANT_COMMITTER_IDENT,
1598+
state->committer_email, WANT_COMMITTER_IDENT,
15991599
state->ignore_date ? NULL
16001600
: state->author_date,
16011601
IDENT_STRICT);

t/t3436-rebase-more-options.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test_ctime_is_atime () {
7070
test_cmp authortime committertime
7171
}
7272

73-
test_expect_failure '--committer-date-is-author-date works with apply backend' '
73+
test_expect_success '--committer-date-is-author-date works with apply backend' '
7474
GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author &&
7575
git rebase --apply --committer-date-is-author-date HEAD^ &&
7676
test_ctime_is_atime -1

0 commit comments

Comments
 (0)