summaryrefslogtreecommitdiff
path: root/t/t3511-cherry-pick-x.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-05-16 02:51:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-16 02:51:52 (GMT)
commit6ebfa10439e50175f24874b39c16fea6560adefe (patch)
tree061a467e9741d800629eb2558aa2428bda0283ae /t/t3511-cherry-pick-x.sh
parent4b44b7b1df44d371eaf3fbed75829d1a749bc7df (diff)
parent44dc738a39f2c4dba41c0ddacae280d0f88dc71f (diff)
downloadgit-6ebfa10439e50175f24874b39c16fea6560adefe.zip
git-6ebfa10439e50175f24874b39c16fea6560adefe.tar.gz
git-6ebfa10439e50175f24874b39c16fea6560adefe.tar.bz2
Merge branch 'jt/use-trailer-api-in-commands'
"git cherry-pick" and other uses of the sequencer machinery mishandled a trailer block whose last line is an incomplete line. This has been fixed so that an additional sign-off etc. are added after completing the existing incomplete line. * jt/use-trailer-api-in-commands: sequencer: add newline before adding footers
Diffstat (limited to 't/t3511-cherry-pick-x.sh')
-rwxr-xr-xt/t3511-cherry-pick-x.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/t/t3511-cherry-pick-x.sh b/t/t3511-cherry-pick-x.sh
index bf0a5c9..9888bf3 100755
--- a/t/t3511-cherry-pick-x.sh
+++ b/t/t3511-cherry-pick-x.sh
@@ -208,6 +208,50 @@ test_expect_success 'cherry-pick -x -s adds sob even when trailing sob exists fo
test_cmp expect actual
'
+test_expect_success 'cherry-pick -x handles commits with no NL at end of message' '
+ pristine_detach initial &&
+ printf "title\n\nSigned-off-by: A <a@example.com>" >msg &&
+ sha1=$(git commit-tree -p initial mesg-with-footer^{tree} <msg) &&
+ git cherry-pick -x $sha1 &&
+ git log -1 --pretty=format:%B >actual &&
+
+ printf "\n(cherry picked from commit %s)\n" $sha1 >>msg &&
+ test_cmp msg actual
+'
+
+test_expect_success 'cherry-pick -x handles commits with no footer and no NL at end of message' '
+ pristine_detach initial &&
+ printf "title\n\nnot a footer" >msg &&
+ sha1=$(git commit-tree -p initial mesg-with-footer^{tree} <msg) &&
+ git cherry-pick -x $sha1 &&
+ git log -1 --pretty=format:%B >actual &&
+
+ printf "\n\n(cherry picked from commit %s)\n" $sha1 >>msg &&
+ test_cmp msg actual
+'
+
+test_expect_success 'cherry-pick -s handles commits with no NL at end of message' '
+ pristine_detach initial &&
+ printf "title\n\nSigned-off-by: A <a@example.com>" >msg &&
+ sha1=$(git commit-tree -p initial mesg-with-footer^{tree} <msg) &&
+ git cherry-pick -s $sha1 &&
+ git log -1 --pretty=format:%B >actual &&
+
+ printf "\nSigned-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>\n" >>msg &&
+ test_cmp msg actual
+'
+
+test_expect_success 'cherry-pick -s handles commits with no footer and no NL at end of message' '
+ pristine_detach initial &&
+ printf "title\n\nnot a footer" >msg &&
+ sha1=$(git commit-tree -p initial mesg-with-footer^{tree} <msg) &&
+ git cherry-pick -s $sha1 &&
+ git log -1 --pretty=format:%B >actual &&
+
+ printf "\n\nSigned-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>\n" >>msg &&
+ test_cmp msg actual
+'
+
test_expect_success 'cherry-pick -x treats "(cherry picked from..." line as part of footer' '
pristine_detach initial &&
sha1=$(git rev-parse mesg-with-cherry-footer^0) &&