@@ -40,6 +40,8 @@ test_expect_success 'setup: messages' '
4040 dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
4141 dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te
4242 feugait nulla facilisi.
43+
44+ Reported-by: A N Other <a.n.other@example.com>
4345 EOF
4446
4547 cat >failmail <<-\EOF &&
@@ -93,7 +95,7 @@ test_expect_success setup '
9395 echo world >>file &&
9496 git add file &&
9597 test_tick &&
96- git commit -s - F msg &&
98+ git commit -F msg &&
9799 git tag second &&
98100
99101 git format-patch --stdout first >patch1 &&
@@ -124,8 +126,6 @@ test_expect_success setup '
124126 echo "Date: $GIT_AUTHOR_DATE" &&
125127 echo &&
126128 sed -e "1,2d" msg &&
127- echo &&
128- echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
129129 echo "---" &&
130130 git diff-tree --no-commit-id --stat -p second
131131 } >patch1-stgit.eml &&
@@ -144,8 +144,6 @@ test_expect_success setup '
144144 echo "# Parent $_z40" &&
145145 cat msg &&
146146 echo &&
147- echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
148- echo &&
149147 git diff-tree --no-commit-id -p second
150148 } >patch1-hg.eml &&
151149
@@ -470,13 +468,15 @@ test_expect_success 'am --signoff adds Signed-off-by: line' '
470468 git reset --hard &&
471469 git checkout -b master2 first &&
472470 git am --signoff <patch2 &&
473- printf "%s\n" "$signoff" >expected &&
474- echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >>expected &&
475- git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
476- test_cmp expected actual &&
477- echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
478- git cat-file commit HEAD | grep "Signed-off-by:" >actual &&
479- test_cmp expected actual
471+ {
472+ printf "third\n\nSigned-off-by: %s <%s>\n\n" \
473+ "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" &&
474+ cat msg &&
475+ printf "Signed-off-by: %s <%s>\n\n" \
476+ "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL"
477+ } >expected-log &&
478+ git log --pretty=%B -2 HEAD >actual &&
479+ test_cmp expected-log actual
480480'
481481
482482test_expect_success ' am stays in branch' '
@@ -486,17 +486,60 @@ test_expect_success 'am stays in branch' '
486486'
487487
488488test_expect_success ' am --signoff does not add Signed-off-by: line if already there' '
489- git format-patch --stdout HEAD^ >patch3 &&
490- sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2] [foo," patch3 >patch4 &&
491- rm -fr .git/rebase-apply &&
492- git reset --hard &&
493- git checkout HEAD^ &&
494- git am --signoff patch4 &&
495- git cat-file commit HEAD >actual &&
496- test $(grep -c "^Signed-off-by:" actual) -eq 1
489+ git format-patch --stdout first >patch3 &&
490+ git reset --hard first &&
491+ git am --signoff <patch3 &&
492+ git log --pretty=%B -2 HEAD >actual &&
493+ test_cmp expected-log actual
494+ '
495+
496+ test_expect_success ' am --signoff adds Signed-off-by: if another author is preset' '
497+ NAME="A N Other" &&
498+ EMAIL="a.n.other@example.com" &&
499+ {
500+ printf "third\n\nSigned-off-by: %s <%s>\nSigned-off-by: %s <%s>\n\n" \
501+ "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" \
502+ "$NAME" "$EMAIL" &&
503+ cat msg &&
504+ printf "Signed-off-by: %s <%s>\nSigned-off-by: %s <%s>\n\n" \
505+ "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" \
506+ "$NAME" "$EMAIL"
507+ } >expected-log &&
508+ git reset --hard first &&
509+ GIT_COMMITTER_NAME="$NAME" GIT_COMMITTER_EMAIL="$EMAIL" \
510+ git am --signoff <patch3 &&
511+ git log --pretty=%B -2 HEAD >actual &&
512+ test_cmp expected-log actual
513+ '
514+
515+ test_expect_success ' am --signoff duplicates Signed-off-by: if it is not the last one' '
516+ NAME="A N Other" &&
517+ EMAIL="a.n.other@example.com" &&
518+ {
519+ printf "third\n\nSigned-off-by: %s <%s>\n\
520+ Signed-off-by: %s <%s>\nSigned-off-by: %s <%s>\n\n" \
521+ "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" \
522+ "$NAME" "$EMAIL" \
523+ "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" &&
524+ cat msg &&
525+ printf "Signed-off-by: %s <%s>\nSigned-off-by: %s <%s>\n\
526+ Signed-off-by: %s <%s>\n\n" \
527+ "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" \
528+ "$NAME" "$EMAIL" \
529+ "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL"
530+ } >expected-log &&
531+ git format-patch --stdout first >patch3 &&
532+ git reset --hard first &&
533+ git am --signoff <patch3 &&
534+ git log --pretty=%B -2 HEAD >actual &&
535+ test_cmp expected-log actual
497536'
498537
499538test_expect_success ' am without --keep removes Re: and [PATCH] stuff' '
539+ git format-patch --stdout HEAD^ >tmp &&
540+ sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2] [foo," tmp >patch4 &&
541+ git reset --hard HEAD^ &&
542+ git am <patch4 &&
500543 git rev-parse HEAD >expected &&
501544 git rev-parse master2 >actual &&
502545 test_cmp expected actual
0 commit comments