{"thread":{"id":"2842","subject":"git rebase loses author name/email if given bad email address","startedAt":"2005-12-14T22:48:19Z","lastAt":"2005-12-15T00:33:01Z","messageCount":2,"participants":["Amos Waterland","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"13641","messageId":"20051214224818.GA5362@kvasir.watson.ibm.com","threadId":"2842","inReplyTo":null,"subject":"git rebase loses author name/email if given bad email address","fromName":"Amos Waterland","fromEmail":"apw@us.ibm.com","sentAt":"2005-12-14T22:48:19Z","receivedAt":"2005-12-14T22:48:19Z","isPatch":false,"sender":{"key":"apw@debian.org","avatar":null},"body":"If GIT_AUTHOR_EMAIL is of a certain form, `git rebase master' will blow\naway the author name and email when fast-forward merging commits.  I\nhave not tracked it down, but here is a testcase that demonstrates the\nbehavior.\n\nSigned-off-by: Amos Waterland <apw@us.ibm.com>\nAcked-by: Michal Ostrowski <mostrows@watson.ibm.com>\n\n---\n\n t/t3400-rebase.sh |   34 ++++++++++++++++++++++++++++++++++\n 1 files changed, 34 insertions(+), 0 deletions(-)\n create mode 100755 t/t3400-rebase.sh\n\n6a31c31a8e6bf4328fab39f39926af6bcc794bf2\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nnew file mode 100755\nindex 0000000..b9d3131\n--- /dev/null\n+++ b/t/t3400-rebase.sh\n@@ -0,0 +1,34 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Amos Waterland\n+#\n+\n+test_description='git rebase should not destroy author information\n+\n+This test runs git rebase and checks that the author information is not lost.\n+'\n+. ./test-lib.sh\n+\n+export GIT_AUTHOR_EMAIL=bogus_email_address\n+\n+test_expect_success \\\n+    'prepare repository with topic branch, then rebase against master' \\\n+    'echo First > A &&\n+     git-update-index --add A &&\n+     git-commit -m \"Add A.\" &&\n+     git checkout -b my-topic-branch &&\n+     echo Second > B &&\n+     git-update-index --add B &&\n+     git-commit -m \"Add B.\" &&\n+     git checkout -f master &&\n+     echo Third >> A &&\n+     git-update-index A &&\n+     git-commit -m \"Modify A.\" &&\n+     git checkout -f my-topic-branch &&\n+     git rebase master'\n+\n+test_expect_failure \\\n+    'the rebase operation should not have destroyed author information' \\\n+    'git log | grep \"Author:\" | grep \"<>\"'\n+\n+test_done\n-- \n0.99.9.GIT\n"},{"id":"13652","messageId":"7virtrurlu.fsf@assigned-by-dhcp.cox.net","threadId":"2842","inReplyTo":"20051214224818.GA5362@kvasir.watson.ibm.com","subject":"Re: git rebase loses author name/email if given bad email address","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-15T00:33:01Z","receivedAt":"2005-12-15T00:33:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Amos Waterland <apw@us.ibm.com> writes:\n\n> If GIT_AUTHOR_EMAIL is of a certain form, `git rebase master' will blow\n> away the author name and email when fast-forward merging commits.\n\nTrue.\n\n> +export GIT_AUTHOR_EMAIL=bogus_email_address\n\nDo not do that, then ;-).\n\nThe rebasing involves extracting the patch as an e-mail form and\nfeeding it to the normal e-mail patch acceptance mechanism, and\nmailinfo.c::handle_from() rejects \"A U Thor <bogus_address>\"\nhence you lose the authorship information.\n\nHaving said that, maybe e-mail acceptance machinery should\nreject such patch.\n\n-- >8 --\nSubject: [PATCH] mailinfo and git-am: allow \"John Doe <johndoe>\"\n\nAn isolated developer could have a local-only e-mail, which will\nbe stripped out by mailinfo because it lacks '@'.  Define a\nfallback parser to accomodate that.\n\nAt the same time, reject authorless patch in git-am.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n git-am.sh  |    7 +++++++\n mailinfo.c |   32 +++++++++++++++++++++++++++++++-\n 2 files changed, 38 insertions(+), 1 deletions(-)\n\ne0e3ba208d235ab5623a86204fbd20b449520764\ndiff --git a/git-am.sh b/git-am.sh\nindex 343bee9..1a114bc 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -249,6 +249,13 @@ do\n \tGIT_AUTHOR_NAME=\"$(sed -n '/^Author/ s/Author: //p' \"$dotest/info\")\"\n \tGIT_AUTHOR_EMAIL=\"$(sed -n '/^Email/ s/Email: //p' \"$dotest/info\")\"\n \tGIT_AUTHOR_DATE=\"$(sed -n '/^Date/ s/Date: //p' \"$dotest/info\")\"\n+\n+\tif test -z \"$GIT_AUTHOR_EMAIL\"\n+\tthen\n+\t\techo \"Patch does not have a valid e-mail address.\"\n+\t\tstop_here $this\n+\tfi\n+\n \texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n \n \tSUBJECT=\"$(sed -n '/^Subject/ s/Subject: //p' \"$dotest/info\")\"\ndiff --git a/mailinfo.c b/mailinfo.c\nindex d4b4163..9f95f37 100644\n--- a/mailinfo.c\n+++ b/mailinfo.c\n@@ -40,13 +40,43 @@ static char *sanity_check(char *name, ch\n \treturn name;\n }\n \n+static int bogus_from(char *line)\n+{\n+\t/* John Doe <johndoe> */\n+\tchar *bra, *ket, *dst, *cp;\n+\n+\t/* This is fallback, so do not bother if we already have an\n+\t * e-mail address.\n+\t */ \n+\tif (*email)\n+\t\treturn 0;\n+\n+\tbra = strchr(line, '<');\n+\tif (!bra)\n+\t\treturn 0;\n+\tket = strchr(bra, '>');\n+\tif (!ket)\n+\t\treturn 0;\n+\n+\tfor (dst = email, cp = bra+1; cp < ket; )\n+\t\t*dst++ = *cp++;\n+\t*dst = 0;\n+\tfor (cp = line; isspace(*cp); cp++)\n+\t\t;\n+\tfor (bra--; isspace(*bra); bra--)\n+\t\t*bra = 0;\n+\tcp = sanity_check(cp, email);\n+\tstrcpy(name, cp);\n+\treturn 1;\n+}\n+\n static int handle_from(char *line)\n {\n \tchar *at = strchr(line, '@');\n \tchar *dst;\n \n \tif (!at)\n-\t\treturn 0;\n+\t\treturn bogus_from(line);\n \n \t/*\n \t * If we already have one email, don't take any confusing lines\n-- \n0.99.9m\n"}]}