git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] am: fix broken email with --committer-date-is-author-date

From
Jeff King <peff@peff.net>
Date
Oct 23, 2020, 07:09 UTC
Message-ID
<20201023070939.GB2913115@coredump.intra.peff.net>
In-Reply-To
<20201023070747.GA2198273@coredump.intra.peff.net>

Commit e8cbe2118a (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 <peff@peff.net>
---
 builtin/am.c                   | 4 ++--
 t/t3436-rebase-more-options.sh | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/am.c b/builtin/am.c
index 2c7673f74e..4949535a7f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -161,7 +161,7 @@ static void am_state_init(struct am_state *state)
 	state->committer_name =
 		xmemdupz(id.name_begin, id.name_end - id.name_begin);
 	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)
 
 	if (state->committer_date_is_author_date)
 		committer = fmt_ident(state->committer_name,
-				      state->author_email, WANT_COMMITTER_IDENT,
+				      state->committer_email, WANT_COMMITTER_IDENT,
 				      state->ignore_date ? NULL
 							 : state->author_date,
 				      IDENT_STRICT);
diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
index 6f2f49717b..3fda2235bd 100755
--- a/t/t3436-rebase-more-options.sh
+++ b/t/t3436-rebase-more-options.sh
@@ -70,7 +70,7 @@ test_ctime_is_atime () {
 	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 rebase --apply --committer-date-is-author-date HEAD^ &&
 	test_ctime_is_atime -1
-- 
2.29.0.583.g8e3ac41d8f
Previous: Phillip WoodNext: Jeff King
Message 5 of 17 in “committer-date-is-author-date flag removes email in "Commit"”
  1. VenomVendorOct 23, 2020
  2. Jeff KingOct 23, 2020
  3. 1/3 t3436: check --committer-date-is-author-date result more carefullyJeff King, Oct 23, 2020
  4. Phillip WoodOct 23, 2020
  5. 2/3 am: fix broken email with --committer-date-is-author-dateJeff King, Oct 23, 2020
  6. 4/3 am, sequencer: stop parsing our own committer identJeff King, Oct 23, 2020
  7. Jeff KingOct 23, 2020
  8. Taylor BlauOct 23, 2020
  9. Johannes SchindelinOct 26, 2020
  10. Jeff KingOct 27, 2020
  11. Phillip WoodOct 23, 2020
  12. Junio C HamanoOct 26, 2020
  13. Jeff KingOct 27, 2020
  14. 3/3 rebase: fix broken email with --committer-date-is-author-dateJeff King, Oct 23, 2020
  15. Junio C HamanoOct 23, 2020
  16. Phillip WoodOct 23, 2020
  17. Junio C HamanoOct 23, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.