git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Noam Yorav-Raphael <noamraph@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Regarding howto/revert-a-faulty-merge.txt - another way to revert a merge
Date: Tue, 25 Jun 2024 02:03:46 -0700	[thread overview]
Message-ID: <xmqqo77p8kct.fsf@gitster.g> (raw)
In-Reply-To: <CAO8o=D5womGcsVsGT4h2=3qry05mMrd9dFDkZHrLtPCDw0+2Tg@mail.gmail.com> (Noam Yorav-Raphael's message of "Mon, 24 Jun 2024 13:17:25 +0300")

Noam Yorav-Raphael <noamraph@gmail.com> writes:

> This is fine, but it means that you must remember to revert the revert
> before the next merge, which may be hard to remember. I thought of
> another solution: In the source branch, add a commit reverting all the
> changes since the previous merge, then merge again from that brange to
> the master branch, and then revert the revert. In a diagram:
>
> ----o---o---o---M---o---o------------W-------
>        /       /                    /
> ------o---A---B---C-------!C!B!A---o----ABC--
>
> (`!C!B!A` means a commit that reverts C, B and A, returning to `o`.
> `ABC` means a commit that applies A, B and C, thus returning to the
> tree after C.)

These, we definitely do not want them [*].

> Now the W commit really reverts the M commit, and you can forget about it.
>
> Would you be interested in a patch adding this to
> howto/revert-a-faulty-merge.txt?

What you have above is a moral equivalent to the "On the other hand"
senario.  In the picture in the existing document, the new
incarnation of A'-B'-C' chain folks from the commit after W, but it
does not have to (it could even be a fork from the original A^).
IOW, there is no need for the A'-B'-C' chain to be strict descendant
of the original C like the above picture.

What happens in practice (and I do this myself sometimes when I have
to revert out a topic out of 'next') is

 * Revert W of a merge M is made.

 * At the very same time, the original A--B--C chain is discarded,
   and the topic is rebased on some appropriate base (e.g. the
   parent of original A in your picture, for example, or the commit
   after W in the "On the other hand" part of the exicting document,
   exact base chosen does not matter all that much) to create an
   updated A'--B'--C' commits.  While this chain is being polished
   (without getting merged into the integration branch to become a
   descendant of W), you may rebase them again and again until they
   are polished enough.  And then you merge the result, which will
   lead to "If you reverted the revert in such a case" topology in
   the existing document.

So if you want to avoid "we can forget that we have reverted"
problem, not reverting the revert, but rebuilding the entire chain,
is a better approach that gives you cleanest history to work with,
and that is what we already offer as an alternative of "reverting a
revert", not "squashed revert and squashed reapply on the side
branch".

So, I dunno if we want to add yet another one.


[Footnote]

 * We do not want the squashed CBA!!! revert or ABC reapply, both of
   which are large balls of wax that interferes with bisectability.

  reply	other threads:[~2024-06-25  9:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24 10:17 Regarding howto/revert-a-faulty-merge.txt - another way to revert a merge Noam Yorav-Raphael
2024-06-25  9:03 ` Junio C Hamano [this message]
2024-06-26 12:17   ` Noam Yorav-Raphael

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=xmqqo77p8kct.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=noamraph@gmail.com \
    /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).