@@ -40,6 +40,8 @@ test_expect_success 'setup: messages' '
40
40
dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
41
41
dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te
42
42
feugait nulla facilisi.
43
+
44
+ Reported-by: A N Other <[email protected] >
43
45
EOF
44
46
45
47
cat >failmail <<-\EOF &&
@@ -93,7 +95,7 @@ test_expect_success setup '
93
95
echo world >>file &&
94
96
git add file &&
95
97
test_tick &&
96
- git commit -s - F msg &&
98
+ git commit -F msg &&
97
99
git tag second &&
98
100
99
101
git format-patch --stdout first >patch1 &&
@@ -124,8 +126,6 @@ test_expect_success setup '
124
126
echo "Date: $GIT_AUTHOR_DATE" &&
125
127
echo &&
126
128
sed -e "1,2d" msg &&
127
- echo &&
128
- echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
129
129
echo "---" &&
130
130
git diff-tree --no-commit-id --stat -p second
131
131
} >patch1-stgit.eml &&
@@ -144,8 +144,6 @@ test_expect_success setup '
144
144
echo "# Parent $_z40" &&
145
145
cat msg &&
146
146
echo &&
147
- echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
148
- echo &&
149
147
git diff-tree --no-commit-id -p second
150
148
} >patch1-hg.eml &&
151
149
@@ -470,13 +468,15 @@ test_expect_success 'am --signoff adds Signed-off-by: line' '
470
468
git reset --hard &&
471
469
git checkout -b master2 first &&
472
470
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
480
480
'
481
481
482
482
test_expect_success ' am stays in branch' '
@@ -486,17 +486,60 @@ test_expect_success 'am stays in branch' '
486
486
'
487
487
488
488
test_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
+
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
+
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
497
536
'
498
537
499
538
test_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 &&
500
543
git rev-parse HEAD >expected &&
501
544
git rev-parse master2 >actual &&
502
545
test_cmp expected actual
0 commit comments