Skip to content

Commit

Permalink
Merge branch 'js/maint-am-rebase-invalid-author' into maint
Browse files Browse the repository at this point in the history
* js/maint-am-rebase-invalid-author:
  am: use get_author_ident_from_commit instead of mailinfo when rebasing
  • Loading branch information
Junio C Hamano committed Jun 28, 2010
2 parents 6c1c442 + 43c2325 commit 339aec7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 10 additions & 4 deletions git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ do
echo "Patch is empty. Was it split wrong?"
stop_here $this
}
rm -f "$dotest/original-commit"
rm -f "$dotest/original-commit" "$dotest/author-script"
if test -f "$dotest/rebasing" &&
commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
-e q "$dotest/$msgnum") &&
Expand All @@ -602,6 +602,7 @@ do
git cat-file commit "$commit" |
sed -e '1,/^$/d' >"$dotest/msg-clean"
echo "$commit" > "$dotest/original-commit"
get_author_ident_from_commit "$commit" > "$dotest/author-script"
else
{
sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
Expand All @@ -613,9 +614,14 @@ do
;;
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 -f "$dotest/author-script"
then
eval $(cat "$dotest/author-script")
else
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

if test -z "$GIT_AUTHOR_EMAIL"
then
Expand Down
9 changes: 7 additions & 2 deletions t/t3400-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down Expand Up @@ -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})
'
Expand Down

0 comments on commit 339aec7

Please sign in to comment.