Skip to content

Commit bcdfb20

Browse files
committed
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
2 parents 4af574d + 43c2325 commit bcdfb20

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

git-am.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ do
596596
echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
597597
stop_here $this
598598
}
599-
rm -f "$dotest/original-commit"
599+
rm -f "$dotest/original-commit" "$dotest/author-script"
600600
if test -f "$dotest/rebasing" &&
601601
commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
602602
-e q "$dotest/$msgnum") &&
@@ -605,6 +605,7 @@ do
605605
git cat-file commit "$commit" |
606606
sed -e '1,/^$/d' >"$dotest/msg-clean"
607607
echo "$commit" > "$dotest/original-commit"
608+
get_author_ident_from_commit "$commit" > "$dotest/author-script"
608609
else
609610
{
610611
sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
@@ -616,9 +617,14 @@ do
616617
;;
617618
esac
618619

619-
GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
620-
GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
621-
GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
620+
if test -f "$dotest/author-script"
621+
then
622+
eval $(cat "$dotest/author-script")
623+
else
624+
GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
625+
GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
626+
GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
627+
fi
622628

623629
if test -z "$GIT_AUTHOR_EMAIL"
624630
then

t/t3400-rebase.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ among other things.
1010
'
1111
. ./test-lib.sh
1212

13-
GIT_AUTHOR_EMAIL=bogus_email_address
14-
export GIT_AUTHOR_EMAIL
13+
GIT_AUTHOR_NAME=author@name
14+
GIT_AUTHOR_EMAIL=bogus@email@address
15+
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
1516

1617
test_expect_success \
1718
'prepare repository with topic branches' \
@@ -80,6 +81,10 @@ test_expect_success \
8081
'the rebase operation should not have destroyed author information' \
8182
'! (git log | grep "Author:" | grep "<>")'
8283

84+
test_expect_success \
85+
'the rebase operation should not have destroyed author information (2)' \
86+
"git log -1 | grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'"
87+
8388
test_expect_success 'HEAD was detached during rebase' '
8489
test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})
8590
'

0 commit comments

Comments
 (0)