Git development
 help / color / mirror / Atom feed
From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org
Cc: Jay Soffian <jaysoffian@gmail.com>, Junio C Hamano <junio@kernel.org>
Subject: [PATCH] am: gather GIT_AUTHOR_* from original commit when rebasing
Date: Tue, 15 Jun 2010 18:18:12 -0400	[thread overview]
Message-ID: <1276640292-78522-1-git-send-email-jaysoffian@gmail.com> (raw)

In certain situations, commit authorship can contain an invalid
e-mail address. For example, this is the case when working with git
svn repos where the author email has the svn repo UUID appended such
as:

 author@example.com <author@example.com@deadbeef-dead-beef-dead-beefdeadbeef>

In such situations, mailinfo extracts the authorship incorrectly
as it assumes a valid email address.

Regardless, when rebasing the original authorship should be
preserved irrespective of its validity as an email address.

This commit teaches am to gather the GIT_AUTHOR_* variables
from the original commit, bypassing any of mailinfo's assumptions.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
 git-am.sh         |   10 ++++++----
 t/t3400-rebase.sh |    9 +++++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

This is a second take at 
http://article.gmane.org/gmane.comp.version-control.git/148568

diff --git a/git-am.sh b/git-am.sh
index 87ffae2..d009d84 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -602,6 +602,9 @@ do
 			git cat-file commit "$commit" |
 			sed -e '1,/^$/d' >"$dotest/msg-clean"
 			echo "$commit" > "$dotest/original-commit"
+			GIT_AUTHOR_NAME="$(GIT_PAGER='' git log --format=%an -1 "$commit")"
+			GIT_AUTHOR_EMAIL="$(GIT_PAGER='' git log --format=%ae -1 "$commit")"
+			GIT_AUTHOR_DATE="$(GIT_PAGER='' git log --format=%aD -1 "$commit")"
 		else
 			{
 				sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
@@ -609,14 +612,13 @@ do
 				cat "$dotest/msg"
 			} |
 			git stripspace > "$dotest/msg-clean"
+			GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
+			GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
+			GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
 		fi
 		;;
 	esac
 
-	GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
-	GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
-	GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
-
 	if test -z "$GIT_AUTHOR_EMAIL"
 	then
 		echo "Patch does not have a valid e-mail address."
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index dbf7dfb..c41bcc7 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -10,8 +10,9 @@ among other things.
 '
 . ./test-lib.sh
 
-GIT_AUTHOR_EMAIL=bogus_email_address
-export GIT_AUTHOR_EMAIL
+GIT_AUTHOR_NAME=author@name
+GIT_AUTHOR_EMAIL=bogus@email@address
+export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
 
 test_expect_success \
     'prepare repository with topic branches' \
@@ -80,6 +81,10 @@ test_expect_success \
     'the rebase operation should not have destroyed author information' \
     '! (git log | grep "Author:" | grep "<>")'
 
+test_expect_success \
+    'the rebase operation should not have destroyed author information (2)' \
+    "git log -1 | grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'"
+
 test_expect_success 'HEAD was detached during rebase' '
      test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})
 '
-- 
1.7.1

             reply	other threads:[~2010-06-15 22:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15 22:18 Jay Soffian [this message]
2010-06-15 22:24 ` [PATCH] am: gather GIT_AUTHOR_* from original commit when rebasing Jay Soffian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1276640292-78522-1-git-send-email-jaysoffian@gmail.com \
    --to=jaysoffian@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junio@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox