Re: [PATCH] cherry-pick: don't barf when there's nothing to do
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:32
Felipe Contreras [off-list ref] writes:
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 <redacted> ---
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.
quoted hunk ↗ jump to hunk
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")); }