git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Jay Soffian <jaysoffian@gmail.com>
Cc: git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH v2] Introduce CHERRY_PICK_HEAD
Date: Wed, 16 Feb 2011 15:42:36 -0600	[thread overview]
Message-ID: <20110216214236.GC2615@elie> (raw)
In-Reply-To: <1297876835-70613-1-git-send-email-jaysoffian@gmail.com>

Jay Soffian wrote:

> When a cherry-pick conflicts git advises to use:
>
>  $ git commit -c <original commit id>
>
> to preserve the original commit message and authorship. Instead, let's
> record the original commit id in CHERRY_PICK_HEAD and advise to use:
>
>   $ git commit -c CHERRY_PICK_HEAD
>
> In the next commit, we teach git to handle the '-c CHERRY_PICK_HEAD'
> part. Note that we record CHERRY_PICK_HEAD even in the case where there
> are no conflicts so that we may use it to communicate authorship to
> commit; this will then allow us to remove set_author_ident_env from
> revert.c.

This "In the next commit" phrasing is dangerous, since a person can
build on top of your first commit at any time. :)  I would say:

	A later patch will teach "git commit" without -c to use
	CHERRY_PICK_HEAD to set the authorship automatically. Note
	that[...]

[...]
> +++ b/builtin/revert.c
> @@ -263,6 +279,11 @@ static void print_advice(void)
>  
>  	if (msg) {
>  		fprintf(stderr, "%s\n", msg);
> +		/*
> +		 * rebase interactive takes care of the authorship
> +		 * when the user invokes rebase --continue
> +		 */
> +		unlink(git_path("CHERRY_PICK_HEAD"));

Nit: GIT_CHERRY_PICK_HELP is not just for rebase --interactive but
for arbitrary porcelain that wants to take care of the commit itself
(see v1.5.4-rc0~106^2~1, revert/cherry-pick: Allow overriding the
help text by the calling Porcelain, 2007-11-28).

The conservative thing to do is indeed to remove CHERRY_PICK_HEAD in
this case, I suppose.  But I'd like to have the CHERRY_PICK_HEAD to
get the --amend safety when rebasing.  I can send a separate patch
for it if you'd like.

> --- a/t/t3507-cherry-pick-conflict.sh
> +++ b/t/t3507-cherry-pick-conflict.sh
> @@ -11,6 +11,12 @@ test_description='test cherry-pick and revert with conflicts
[...]
> +test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '

Some more tests.  Yes, they are repetitive.  A patch on top to factor
out the setup into a function might help, but that feels out of scope
here.

With whatever subset of the below looks good,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

Thanks.
---
 t/t3507-cherry-pick-conflict.sh |  116 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
index fd569c8..ea52720 100755
--- a/t/t3507-cherry-pick-conflict.sh
+++ b/t/t3507-cherry-pick-conflict.sh
@@ -78,6 +78,122 @@ test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '
 	test_cmp_rev picked CHERRY_PICK_HEAD
 '
 
+test_expect_success 'successful cherry-pick does not set CHERRY_PICK_HEAD' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	git cherry-pick base &&
+
+	test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
+test_expect_success 'cherry-pick --no-commit sets CHERRY_PICK_HEAD' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	git cherry-pick --no-commit base &&
+
+	test_cmp_rev base CHERRY_PICK_HEAD
+'
+
+test_expect_success 'GIT_CHERRY_PICK_HELP suppresses CHERRY_PICK_HEAD' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	(
+		GIT_CHERRY_PICK_HELP="and then do something else" &&
+		export GIT_CHERRY_PICK_HELP &&
+		test_must_fail git cherry-pick picked
+	) &&
+
+	test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
+test_expect_success 'git reset clears CHERRY_PICK_HEAD' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git cherry-pick picked &&
+	git reset &&
+
+	test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
+test_expect_success 'failed commit does not clear CHERRY_PICK_HEAD' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git cherry-pick picked &&
+	test_must_fail git commit &&
+
+	test_cmp_rev picked CHERRY_PICK_HEAD
+'
+
+test_expect_success 'cancelled commit does not clear CHERRY_PICK_HEAD' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git cherry-pick picked &&
+	echo resolved >foo &&
+	git add foo &&
+	git update-index --refresh -q &&
+	test_must_fail git diff-index --exit-code HEAD &&
+	(
+		GIT_EDITOR=false &&
+		export GIT_EDITOR &&
+		test_must_fail git commit
+	) &&
+
+	test_cmp_rev picked CHERRY_PICK_HEAD
+'
+
+test_expect_success 'successful commit clears CHERRY_PICK_HEAD' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git cherry-pick picked &&
+	echo resolved >foo &&
+	git add foo &&
+	git commit &&
+
+	test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
 test_expect_success 'failed cherry-pick produces dirty index' '
 
 	git checkout -f initial^0 &&
-- 
1.7.4.1

  parent reply	other threads:[~2011-02-16 21:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-16 10:08 [PATCH 0/2] CHERRY_PICK_HEAD Jay Soffian
2011-02-16 10:08 ` [PATCH 1/2] Introduce CHERRY_PICK_HEAD Jay Soffian
2011-02-16 11:13   ` Nguyen Thai Ngoc Duy
2011-02-16 16:50     ` Jay Soffian
2011-02-16 17:20   ` [PATCH v2] " Jay Soffian
2011-02-16 17:25     ` Jay Soffian
2011-02-16 21:42     ` Jonathan Nieder [this message]
2011-02-16 22:13       ` Jay Soffian
2011-02-16 23:02         ` Jonathan Nieder
2011-02-17 19:58           ` Junio C Hamano
2011-02-17 22:16             ` Jonathan Nieder
2011-02-16 10:08 ` [PATCH 2/2] Teach commit about CHERRY_PICK_HEAD Jay Soffian
2011-02-16 21:07   ` Junio C Hamano
2011-02-16 21:33     ` Jay Soffian
2011-02-16 21:55   ` [PATCH 1.5/2] bash: teach __git_ps1 " Jonathan Nieder
2011-02-16 22:49     ` Junio C Hamano
2011-02-16 22:43   ` [PATCH 2/2] Teach commit " Jonathan Nieder
2011-02-17  0:05     ` Jay Soffian

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=20110216214236.GC2615@elie \
    --to=jrnieder@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jaysoffian@gmail.com \
    /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).