Merge branch 'js/maint-am-rebase-invalid-author'

* js/maint-am-rebase-invalid-author:
  am: use get_author_ident_from_commit instead of mailinfo when rebasing
This commit is contained in:
Junio C Hamano 2010-06-27 12:07:44 -07:00
commit bcdfb20ae9
2 changed files with 17 additions and 6 deletions

View File

@ -596,7 +596,7 @@ do
echo "To restore the original branch and stop patching run \"$cmdline --abort\"." echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
stop_here $this stop_here $this
} }
rm -f "$dotest/original-commit" rm -f "$dotest/original-commit" "$dotest/author-script"
if test -f "$dotest/rebasing" && if test -f "$dotest/rebasing" &&
commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \ commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
-e q "$dotest/$msgnum") && -e q "$dotest/$msgnum") &&
@ -605,6 +605,7 @@ do
git cat-file commit "$commit" | git cat-file commit "$commit" |
sed -e '1,/^$/d' >"$dotest/msg-clean" sed -e '1,/^$/d' >"$dotest/msg-clean"
echo "$commit" > "$dotest/original-commit" echo "$commit" > "$dotest/original-commit"
get_author_ident_from_commit "$commit" > "$dotest/author-script"
else else
{ {
sed -n '/^Subject/ s/Subject: //p' "$dotest/info" sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
@ -616,9 +617,14 @@ do
;; ;;
esac esac
if test -f "$dotest/author-script"
then
eval $(cat "$dotest/author-script")
else
GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")" GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //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")" GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
fi
if test -z "$GIT_AUTHOR_EMAIL" if test -z "$GIT_AUTHOR_EMAIL"
then then

View File

@ -10,8 +10,9 @@ among other things.
' '
. ./test-lib.sh . ./test-lib.sh
GIT_AUTHOR_EMAIL=bogus_email_address GIT_AUTHOR_NAME=author@name
export GIT_AUTHOR_EMAIL GIT_AUTHOR_EMAIL=bogus@email@address
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
test_expect_success \ test_expect_success \
'prepare repository with topic branches' \ 'prepare repository with topic branches' \
@ -80,6 +81,10 @@ test_expect_success \
'the rebase operation should not have destroyed author information' \ 'the rebase operation should not have destroyed author information' \
'! (git log | grep "Author:" | grep "<>")' '! (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_expect_success 'HEAD was detached during rebase' '
test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1}) test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})
' '