git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Miklos Vajna <vmiklos@suse.cz>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH v3] cherry-pick: make sure all input objects are commits
Date: Thu, 09 May 2013 13:27:49 -0700	[thread overview]
Message-ID: <7vsj1v99ve.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vy5bo7x62.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Thu, 09 May 2013 12:47:33 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Miklos Vajna <vmiklos@suse.cz> writes:
>
>> When a single argument was a non-commit, the error message used to be:
>>
>> 	fatal: BUG: expected exactly one commit from walk
>>
>> For multiple arguments, when none of the arguments was a commit, the error was:
>>
>> 	fatal: empty commit set passed
>>
>> Finally, when some of the arguments were non-commits, we ignored those
>> arguments.  Fix this bug and make sure all arguments are commits, and
>> for the first non-commit, error out with:
>>
>> 	fatal: <name>: Can't cherry-pick a <type>
>>
>> Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
>
> This turns out to be an irritatingly stupid change.  While I am
> rebuilding a privately tagged tip of 'maint', I am seeing:
>
> 	fatal: v1.8.2.3: Can't cherry-pick a tag
>
> You would want to reject non committish, not non commit.

I'd apply this before -rc2.  I _think_ it is also OK to just let
lookup_commit_reference_gently() barf with its standard message

	error: Object %s is a %s, not a commit

without an extra sha1_object_info() call in the error codepath, but
I did not bother, as this is meant to be an emergency fix.

-- >8 --
Subject: cherry-pick: picking a tag that resolves to a commit is OK

Earlier, 21246dbb9e0a (cherry-pick: make sure all input objects are
commits, 2013-04-11) tried to catch an unlikely "git cherry-pick $blob"
as an error, but broke a more important use case to cherry-pick a
tag that points at a commit.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 sequencer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 61fdb68..f2c9d98 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1077,10 +1077,10 @@ int sequencer_pick_revisions(struct replay_opts *opts)
 			continue;
 
 		if (!get_sha1(name, sha1)) {
-			enum object_type type = sha1_object_info(sha1, NULL);
-
-			if (type > 0 && type != OBJ_COMMIT)
+			if (!lookup_commit_reference_gently(sha1, 1)) {
+				enum object_type type = sha1_object_info(sha1, NULL);
 				die(_("%s: can't cherry-pick a %s"), name, typename(type));
+			}
 		} else
 			die(_("%s: bad revision"), name);
 	}

  reply	other threads:[~2013-05-09 20:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03  9:27 [PATCH] cherry-pick: better error message when the parameter is a non-commit Miklos Vajna
2013-04-08 12:27 ` Miklos Vajna
2013-04-08 16:45   ` Junio C Hamano
2013-04-08 16:56 ` Junio C Hamano
2013-04-11  9:26   ` [PATCH v2] cherry-pick: make sure all input objects are commits Miklos Vajna
2013-04-11 10:22     ` Ramkumar Ramachandra
2013-04-11 11:03       ` Miklos Vajna
2013-04-11 11:42         ` Ramkumar Ramachandra
2013-04-11 13:06           ` [PATCH v3] " Miklos Vajna
2013-04-11 13:27             ` Ramkumar Ramachandra
2013-04-15  8:44             ` Thomas Rast
2013-04-15 18:29               ` Junio C Hamano
2013-04-15 19:12               ` Junio C Hamano
2013-04-16 14:22                 ` Michael Haggerty
2013-05-09 19:47             ` Junio C Hamano
2013-05-09 20:27               ` Junio C Hamano [this message]
2013-05-10  7:07                 ` Miklos Vajna

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

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

  git send-email \
    --in-reply-to=7vsj1v99ve.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=vmiklos@suse.cz \
    /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.
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 NNTP newsgroup(s).