From 5ed75e2a3fb30f93fea7772e481ec6091e9a2c5f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Sep 2012 08:52:03 +0200 Subject: cherry-pick: don't forget -s on failure In case 'git cherry-pick -s ' failed, the user had to use 'git commit -s' (i.e. state the -s option again), which is easy to forget about. Instead, write the signed-off-by line early, so plain 'git commit' will have the same result. Also update 'git commit -s', so that in case there is already a relevant Signed-off-by line before the Conflicts: line, it won't add one more at the end of the message. If there is no such line, then add it before the the Conflicts: line. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t3507-cherry-pick-conflict.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 't/t3507-cherry-pick-conflict.sh') diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 0c81b3c427..c82f7210c4 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -30,6 +30,7 @@ test_expect_success setup ' test_commit initial foo a && test_commit base foo b && test_commit picked foo c && + test_commit --signoff picked-signed foo d && git config advice.detachedhead false ' @@ -340,4 +341,35 @@ test_expect_success 'revert conflict, diff3 -m style' ' test_cmp expected actual ' +test_expect_success 'failed cherry-pick does not forget -s' ' + pristine_detach initial && + test_must_fail git cherry-pick -s picked && + test_i18ngrep -e "Signed-off-by" .git/MERGE_MSG +' + +test_expect_success 'commit after failed cherry-pick does not add duplicated -s' ' + pristine_detach initial && + test_must_fail git cherry-pick -s picked-signed && + git commit -a -s && + test $(git show -s |grep -c "Signed-off-by") = 1 +' + +test_expect_success 'commit after failed cherry-pick adds -s at the right place' ' + pristine_detach initial && + test_must_fail git cherry-pick picked && + git commit -a -s && + pwd && + cat < expected && +picked + +Signed-off-by: C O Mitter + +Conflicts: + foo +EOF + + git show -s --pretty=format:%B > actual && + test_cmp expected actual +' + test_done -- cgit v1.2.3