git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] cherry-pick: don't barf when there's nothing to do

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 3, 2013, 23:20 UTC
Message-ID
<7vtxlebx38.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1369921781-30667-1-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 5 quoted lines
> If the user set --ff, it's expected that if theres's nothing to do we
> fast-forward our current HEAD, which is a no-op.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---

This is about "git cherry-pick topic..master" which is a misspelt form of "git cherry-pick master..topic", or alternatively, a script calling "git cherry-pick ..$branch" that turns out to be giving an empty set, isn't it?

I suspect that it is perfectly fine to turn this die() into a warning or an informational feedback (or be silent when --quiet is given) and make the command exit with success. If the user asked for a no-op, the result should be a no-op, but because a no-op is a strange thing to ask for, and is deserved to be warned about.

But I do not see why we should behave differently between with and without --ff option.

I also notice this funkiness with "--ff":
	git.git/master$ git checkout master^
        git.git/(ed73fe5...)$ git cherry-pick master^0
        [detached HEAD 32af3ed] Update draft release notes to 1.8.4
	 1 file changed, 53 insertions(+)
	git.git/(32af3ed...)$ git checkout master^
        git.git/(ed73fe5...)$ git cherry-pick --ff master^0
        git.git/(b2edae0...)$

The last cherry-pick shows nothing. The user can notice that something useful has happened only because git-prompt script is in use (and he is experimenting on a detached HEAD), but otherwise there is no feedback. I think it should, unless given --quiet, say something like "fast-forwarded to ..." to avoid user confusion.

Show 15 quoted lines
>  sequencer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index d8f9d30..b9d4b48 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -749,7 +749,7 @@ static void prepare_revs(struct replay_opts *opts)
>  	if (prepare_revision_walk(opts->revs))
>  		die(_("revision walk setup failed"));
>  
> -	if (!opts->revs->commits)
> +	if (!opts->revs->commits && !opts->allow_ff)
>  		die(_("empty commit set passed"));
>  }
Previous: Felipe Contreras
Message 2 of 2 in “cherry-pick: don't barf when there's nothing to do”
  1. cherry-pick: don't barf when there's nothing to doFelipe Contreras, May 30, 2013
  2. Junio C HamanoJun 3, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.