{"thread":{"id":"24126","subject":"[PATCH v2] am: gather GIT_AUTHOR_* from original commit when rebasing","startedAt":"2010-06-15T22:39:24Z","lastAt":"2010-06-16T19:06:24Z","messageCount":4,"participants":["Jay Soffian","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"143799","messageId":"1276641564-2074-1-git-send-email-jaysoffian@gmail.com","threadId":"24126","inReplyTo":null,"subject":"[PATCH v2] am: gather GIT_AUTHOR_* from original commit when rebasing","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-06-15T22:39:24Z","receivedAt":"2010-06-15T22:39:24Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"In certain situations, commit authorship can contain an invalid\ne-mail address. For example, this is the case when working with git\nsvn repos where the author email has the svn repo UUID appended such\nas:\n\n author@example.com <author@example.com@deadbeef-dead-beef-dead-beefdeadbeef>\n\nIn such situations, mailinfo extracts the authorship incorrectly\nas it assumes a valid email address.\n\nRegardless, when rebasing the original authorship should be\npreserved irrespective of its validity as an email address.\n\nThis commit teaches am to gather the GIT_AUTHOR_* variables\nfrom the original commit, bypassing any of mailinfo's assumptions.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n git-am.sh         |   14 +++++++++++---\n t/t3400-rebase.sh |    9 +++++++--\n 2 files changed, 18 insertions(+), 5 deletions(-)\n\nThis is a second take at \nhttp://article.gmane.org/gmane.comp.version-control.git/148568\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 87ffae2..568844c 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -613,9 +613,17 @@ do\n \t\t;;\n \tesac\n \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+\tif test -f \"$dotest/original-commit\"\n+\tthen\n+\t\toriginal_commit=\"$(cat \"$dotest/original-commit\")\"\n+\t\tGIT_AUTHOR_NAME=\"$(GIT_PAGER='' git log --format=%an -1 \"$original_commit\")\"\n+\t\tGIT_AUTHOR_EMAIL=\"$(GIT_PAGER='' git log --format=%ae -1 \"$original_commit\")\"\n+\t\tGIT_AUTHOR_DATE=\"$(GIT_PAGER='' git log --format=%aD -1 \"$original_commit\")\"\n+\telse\n+\t\tGIT_AUTHOR_NAME=\"$(sed -n '/^Author/ s/Author: //p' \"$dotest/info\")\"\n+\t\tGIT_AUTHOR_EMAIL=\"$(sed -n '/^Email/ s/Email: //p' \"$dotest/info\")\"\n+\t\tGIT_AUTHOR_DATE=\"$(sed -n '/^Date/ s/Date: //p' \"$dotest/info\")\"\n+\tfi\n \n \tif test -z \"$GIT_AUTHOR_EMAIL\"\n \tthen\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex dbf7dfb..c41bcc7 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -10,8 +10,9 @@ among other things.\n '\n . ./test-lib.sh\n \n-GIT_AUTHOR_EMAIL=bogus_email_address\n-export GIT_AUTHOR_EMAIL\n+GIT_AUTHOR_NAME=author@name\n+GIT_AUTHOR_EMAIL=bogus@email@address\n+export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL\n \n test_expect_success \\\n     'prepare repository with topic branches' \\\n@@ -80,6 +81,10 @@ test_expect_success \\\n     'the rebase operation should not have destroyed author information' \\\n     '! (git log | grep \"Author:\" | grep \"<>\")'\n \n+test_expect_success \\\n+    'the rebase operation should not have destroyed author information (2)' \\\n+    \"git log -1 | grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'\"\n+\n test_expect_success 'HEAD was detached during rebase' '\n      test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})\n '\n-- \n1.7.1\n"},{"id":"143812","messageId":"4C186F9D.1060608@viscovery.net","threadId":"24126","inReplyTo":"1276641564-2074-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH v2] am: gather GIT_AUTHOR_* from original commit when rebasing","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-06-16T06:30:53Z","receivedAt":"2010-06-16T06:30:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 6/16/2010 0:39, schrieb Jay Soffian:\n> +\tif test -f \"$dotest/original-commit\"\n> +\tthen\n> +\t\toriginal_commit=\"$(cat \"$dotest/original-commit\")\"\n> +\t\tGIT_AUTHOR_NAME=\"$(GIT_PAGER='' git log --format=%an -1 \"$original_commit\")\"\n> +\t\tGIT_AUTHOR_EMAIL=\"$(GIT_PAGER='' git log --format=%ae -1 \"$original_commit\")\"\n> +\t\tGIT_AUTHOR_DATE=\"$(GIT_PAGER='' git log --format=%aD -1 \"$original_commit\")\"\n\nI think you can use the function get_author_ident_from_commit() for this.\nSee git-sh-setup.\n\n-- Hannes\n"},{"id":"143813","messageId":"1276672360-15816-1-git-send-email-jaysoffian@gmail.com","threadId":"24126","inReplyTo":"4C186F9D.1060608@viscovery.net","subject":"[PATCH v3] am: use get_author_ident_from_commit instead of mailinfo when rebasing","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-06-16T07:12:40Z","receivedAt":"2010-06-16T07:12:40Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"In certain situations, commit authorship can consist of an invalid\ne-mail address. For example, this is the case when working with git svn\nrepos where the author email has had the svn repo UUID appended such as:\n\n author@example.com <author@example.com@deadbeef-dead-beef-dead-beefdeadbeef>\n\nGiven such an address, mailinfo extracts the authorship incorrectly as\nit assumes a valid domain. However, when rebasing the original\nauthorship should be preserved irrespective of its validity as an email\naddress.\n\nUsing get_author_ident_from_commit instead of mailinfo when rebasing\npreserves the original authorship.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n git-am.sh         |   14 ++++++++++----\n t/t3400-rebase.sh |    9 +++++++--\n 2 files changed, 17 insertions(+), 6 deletions(-)\n\nIncorporated Hannes' suggestion to use get_author_ident_from_commit.\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 87ffae2..1df5b04 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -593,7 +593,7 @@ do\n \t\t\techo \"Patch is empty.  Was it split wrong?\"\n \t\t\tstop_here $this\n \t\t}\n-\t\trm -f \"$dotest/original-commit\"\n+\t\trm -f \"$dotest/original-commit\" \"$dotest/author-script\"\n \t\tif test -f \"$dotest/rebasing\" &&\n \t\t\tcommit=$(sed -e 's/^From \\([0-9a-f]*\\) .*/\\1/' \\\n \t\t\t\t-e q \"$dotest/$msgnum\") &&\n@@ -602,6 +602,7 @@ do\n \t\t\tgit cat-file commit \"$commit\" |\n \t\t\tsed -e '1,/^$/d' >\"$dotest/msg-clean\"\n \t\t\techo \"$commit\" > \"$dotest/original-commit\"\n+\t\t\tget_author_ident_from_commit \"$commit\" > \"$dotest/author-script\"\n \t\telse\n \t\t\t{\n \t\t\t\tsed -n '/^Subject/ s/Subject: //p' \"$dotest/info\"\n@@ -613,9 +614,14 @@ do\n \t\t;;\n \tesac\n \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+\tif test -f \"$dotest/author-script\"\n+\tthen\n+\t\teval $(cat \"$dotest/author-script\")\n+\telse\n+\t\tGIT_AUTHOR_NAME=\"$(sed -n '/^Author/ s/Author: //p' \"$dotest/info\")\"\n+\t\tGIT_AUTHOR_EMAIL=\"$(sed -n '/^Email/ s/Email: //p' \"$dotest/info\")\"\n+\t\tGIT_AUTHOR_DATE=\"$(sed -n '/^Date/ s/Date: //p' \"$dotest/info\")\"\n+\tfi\n \n \tif test -z \"$GIT_AUTHOR_EMAIL\"\n \tthen\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex dbf7dfb..c41bcc7 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -10,8 +10,9 @@ among other things.\n '\n . ./test-lib.sh\n \n-GIT_AUTHOR_EMAIL=bogus_email_address\n-export GIT_AUTHOR_EMAIL\n+GIT_AUTHOR_NAME=author@name\n+GIT_AUTHOR_EMAIL=bogus@email@address\n+export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL\n \n test_expect_success \\\n     'prepare repository with topic branches' \\\n@@ -80,6 +81,10 @@ test_expect_success \\\n     'the rebase operation should not have destroyed author information' \\\n     '! (git log | grep \"Author:\" | grep \"<>\")'\n \n+test_expect_success \\\n+    'the rebase operation should not have destroyed author information (2)' \\\n+    \"git log -1 | grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'\"\n+\n test_expect_success 'HEAD was detached during rebase' '\n      test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})\n '\n-- \n1.7.1\n"},{"id":"143829","messageId":"7vzkyuer0v.fsf@alter.siamese.dyndns.org","threadId":"24126","inReplyTo":"1276672360-15816-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH v3] am: use get_author_ident_from_commit instead of mailinfo when rebasing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-16T19:06:24Z","receivedAt":"2010-06-16T19:06:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> In certain situations, commit authorship can consist of an invalid\n> e-mail address. For example, this is the case when working with git svn\n> repos where the author email has had the svn repo UUID appended such as:\n>\n>  author@example.com <author@example.com@deadbeef-dead-beef-dead-beefdeadbeef>\n>\n> Given such an address, mailinfo extracts the authorship incorrectly as\n> it assumes a valid domain. However, when rebasing the original\n> authorship should be preserved irrespective of its validity as an email\n> address.\n\nThis justifies the motivation very well.  Thanks.\n"}]}