git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Stefan Haller <lists@haller-berlin.de>,
	Junio C Hamano <gitster@pobox.com>
Cc: Git <git@vger.kernel.org>
Subject: Re: Thoughts about the -m option of cherry-pick and revert
Date: Fri, 21 Jun 2024 11:19:31 +0100	[thread overview]
Message-ID: <6e71b1f3-599f-49c3-be37-e499f28983cf@gmail.com> (raw)
In-Reply-To: <dd58a60d-a551-4726-85a7-f47b851914be@haller-berlin.de>

On 21/06/2024 07:33, Stefan Haller wrote:
> On 21.06.24 04:03, Junio C Hamano wrote:
>> Stefan Haller <lists@haller-berlin.de> writes:
 >
> Hm, in all example scenarios I experimented with, picking the wrong
> parent would result in an empty diff, and consequently an error message
> like this:
> 
>     nothing to commit, working tree clean
>     The previous cherry-pick is now empty, possibly due to conflict
>     resolution.
>     If you wish to commit it anyway, use:
> 
>         git commit --allow-empty
> 
>     Otherwise, please use 'git cherry-pick --skip'
> 
> I'm not sure if this error is easier or harder to understand than the
> one you get today when omitting -m, but we could probably improve it by
> mentioning the -m option if the cherry-picked commit was a merge.

That might be helpful - if we do that we'd want to make sure that the 
user can retry this pick with "-m" without restarting the whole cherry-pick.

> I'd be interested in example scenarios where both sides of the merge
> have non-empty diffs. Won't this only happen for evil merges?

I think you'd need a conflicting merge that is resolved in a way that 
the resolution of the conflicting lines doesn't match either parent. (I 
assume that's what you mean by evil but I thought it best to check)

>> If I were simplifying this, I would probably
>>
>>   (1) disallow cherry-picking a merge (and suggest redoing the same
>>       merge, possibly after rebasing the copy of the merged history
>>       to an appropriate base as needed), and
> 
> This seems unnecessarily restrictive to me. Cherry-picking merge commits
> using -m1 is useful, it's an important part of our release workflow at
> my day job.

I can see why people want to revert merges but cherry-picking them 
always feels strange to me - what is the advantage over actually merging 
the branch and seeing the full history of that commit?

>>   (2) allowing reverting a merge only wrt the first parent,
> 
> Interesting, that's what I'm considering doing in lazygit (except for
> both revert and cherry-pick), but I kind of didn't expect much support
> for that idea. :-)

For lazygit I would think it would be fine to be a bit more restrictive 
that git as anyone with an unusual requirement can always fall back to 
using git for that.

Best Wishes

Phillip


> -Stefan
> 


  reply	other threads:[~2024-06-21 10:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 10:05 Thoughts about the -m option of cherry-pick and revert Stefan Haller
2024-06-21  2:03 ` Junio C Hamano
2024-06-21  6:33   ` Stefan Haller
2024-06-21 10:19     ` Phillip Wood [this message]
2024-06-21 11:48       ` Stefan Haller
2024-06-21 16:34       ` Junio C Hamano
2024-06-24  7:33         ` Stefan Haller
2024-06-24 18:43           ` Junio C Hamano
2024-06-21 10:12   ` Phillip Wood

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=6e71b1f3-599f-49c3-be37-e499f28983cf@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lists@haller-berlin.de \
    --cc=phillip.wood@dunelm.org.uk \
    /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).