git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Brandon Casey <drafnel@gmail.com>
To: git@vger.kernel.org
Cc: Brandon Casey <drafnel@gmail.com>, Brandon Casey <bcasey@nvidia.com>
Subject: [PATCH 2/5] t/t3511: demonstrate breakage in cherry-pick -s
Date: Wed, 14 Nov 2012 17:37:51 -0800	[thread overview]
Message-ID: <1352943474-15573-2-git-send-email-drafnel@gmail.com> (raw)
In-Reply-To: <1352943474-15573-1-git-send-email-drafnel@gmail.com>

The cherry-pick -s functionality is currently broken in two ways.

   1. handling of rfc2822 continuation lines has a bug, and the
      continuation lines are not handled correctly.
   2. the "(cherry picked from ...)" lines are commonly appended to the
      end of the s-o-b footer and should be detected as part of the footer.
      They should not cause a new line to be inserted before the new s-o-b
      is added.

      i.e. we should produce this:

         Signed-off-by: A.U. Thor <author@example.com>
         (cherry picked from )
         Signed-off-by: C O Mmitter <committer@example.com>

      not

         Signed-off-by: A.U. Thor <author@example.com>
         (cherry picked from da39a3ee5e6b4b0d3255bfef95601890afd80709)

         Signed-off-by: C O Mmitter <committer@example.com>

Signed-off-by: Brandon Casey <bcasey@nvidia.com>
---
 t/t3511-cherry-pick-x.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100755 t/t3511-cherry-pick-x.sh

diff --git a/t/t3511-cherry-pick-x.sh b/t/t3511-cherry-pick-x.sh
new file mode 100755
index 0000000..b4e5c65
--- /dev/null
+++ b/t/t3511-cherry-pick-x.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+test_description='Test cherry-pick -x and -s'
+
+. ./test-lib.sh
+
+pristine_detach () {
+	git cherry-pick --quit &&
+	git checkout -f "$1^0" &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x
+}
+
+non_rfc2822_mesg='base with footer
+
+Commit message body is here.'
+
+rfc2822_mesg="$non_rfc2822_mesg
+
+Signed-off-by: A.U. Thor
+ <author@example.com>
+Signed-off-by: B.U. Thor <buthor@example.com>"
+
+rfc2822_cherry_mesg="$rfc2822_mesg
+(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
+Tested-by: C.U. Thor <cuthor@example.com>"
+
+
+test_expect_success setup '
+	git config advice.detachedhead false &&
+	echo unrelated >unrelated &&
+	git add unrelated &&
+	test_commit initial foo a &&
+	test_commit "$non_rfc2822_mesg" foo b non-rfc2822-base &&
+	git reset --hard initial &&
+	test_commit "$rfc2822_mesg" foo b rfc2822-base &&
+	git reset --hard initial &&
+	test_commit "$rfc2822_cherry_mesg" foo b rfc2822-cherry-base &&
+	pristine_detach initial &&
+	test_commit conflicting unrelated
+'
+
+test_expect_success 'cherry-pick -s inserts blank line after non-rfc2822 footer' '
+	pristine_detach initial &&
+	git cherry-pick -s non-rfc2822-base &&
+	cat <<-EOF >expect &&
+		$non_rfc2822_mesg
+
+		Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+	EOF
+	git log -1 --pretty=format:%B >actual &&
+	test_cmp expect actual
+'
+
+test_expect_failure 'cherry-pick -s not confused by rfc2822 continuation line' '
+	pristine_detach initial &&
+	git cherry-pick -s rfc2822-base &&
+	cat <<-EOF >expect &&
+		$rfc2822_mesg
+		Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+	EOF
+	git log -1 --pretty=format:%B >actual &&
+	test_cmp expect actual
+'
+
+test_expect_failure 'cherry-pick treats -s "(cherry picked from..." line as part of footer' '
+	pristine_detach initial &&
+	git cherry-pick -s rfc2822-cherry-base &&
+	cat <<-EOF >expect &&
+		$rfc2822_cherry_mesg
+		Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+	EOF
+	git log -1 --pretty=format:%B >actual &&
+	test_cmp expect actual
+'
+
+test_done
-- 
1.8.0

  reply	other threads:[~2012-11-15  1:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15  1:37 [PATCH 1/5] t/test-lib-functions.sh: allow to specify the tag name to test_commit Brandon Casey
2012-11-15  1:37 ` Brandon Casey [this message]
2012-11-16  1:58   ` [PATCH 2/5] t/t3511: demonstrate breakage in cherry-pick -s Junio C Hamano
2012-11-16  2:40     ` Brandon Casey
2012-11-15  1:37 ` [PATCH 3/5] sequencer.c: handle rfc2822 continuation lines correctly Brandon Casey
2012-11-15  1:37 ` [PATCH 4/5] sequencer.c: recognize "(cherry picked from ..." as part of s-o-b footer Brandon Casey
2012-11-15 17:55   ` [PATCH v2 " Brandon Casey
2012-11-15  1:37 ` [PATCH/RFC 5/5] sequencer.c: always separate "(cherry picked from" from commit body Brandon Casey
2012-11-15 23:24   ` [PATCH 6/5] sequencer.c: refrain from adding duplicate s-o-b lines Brandon Casey
2012-11-16  2:03     ` Junio C Hamano
2012-11-16 23:55       ` Brandon Casey
2012-11-15  3:20 ` [PATCH 1/5] t/test-lib-functions.sh: allow to specify the tag name to test_commit Matt Kraai
2012-11-15  5:43   ` Brandon Casey
2012-11-15  5:49   ` [PATCH 1/5 v2] " Brandon Casey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1352943474-15573-2-git-send-email-drafnel@gmail.com \
    --to=drafnel@gmail.com \
    --cc=bcasey@nvidia.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).