From: Junio C Hamano <gitster@pobox•com>
To: Stefan Haller <lists@haller-berlin•de>
Cc: Git <git@vger•kernel.org>
Subject: Re: Thoughts about the -m option of cherry-pick and revert
Date: Thu, 20 Jun 2024 19:03:46 -0700 [thread overview]
Message-ID: <xmqqa5jfoxvh.fsf@gitster.g> (raw)
In-Reply-To: <e60a8b1a-98c8-4ac7-b966-ff9635bb781d@haller-berlin.de> (Stefan Haller's message of "Thu, 20 Jun 2024 12:05:45 +0200")
Stefan Haller <lists@haller-berlin•de> writes:
> I have two questions:
>
> - What are real-world scenarios where you would use a mainline number
> other than 1? I could only come up with a single example myself, which
> is that you have a topic branch, and right before merging it back to
> main, you merge main into the topic branch; and then you merge it to
> main with a fast-forward merge. If you then want to cherry-pick or
> revert that topic, you'd have to use -m2 on that last merge from main.
> Any other examples?
I do think your example is a real issue that is helped by using -m2;
I do not think of any other cases offhand myself.
> - Wouldn't it make sense to default to -m1 when no -m option is given?
> It seems that this would do the expected thing in the vast majority of
> cases.
I do agree -m2 or higher would be rare when doing "git revert".
Given that the current behaviour was chosen to make sure that the
user is aware that the commit being reverted/cherry-picked is a
merge and has a chance to choose the right parent (as opposed to
blindly picking the first parent that happened to be the right one
by accident), I am not sure if it is prudent to change the
behaviour.
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
(2) allowing reverting a merge only wrt the first parent,
but that is a different story.
next prev parent reply other threads:[~2024-06-21 2:03 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 [this message]
2024-06-21 6:33 ` Stefan Haller
2024-06-21 10:19 ` Phillip Wood
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=xmqqa5jfoxvh.fsf@gitster.g \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=lists@haller-berlin$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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