From: Junio C Hamano <gitster@pobox.com>
To: Nanako Shiraishi <nanako3@lavabit.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Alan <alan@clueserver.org>,
git@vger.kernel.org
Subject: Re: Odd merge behaviour involving reverts
Date: Fri, 19 Dec 2008 00:45:19 -0800 [thread overview]
Message-ID: <7vocz8a6zk.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20081219124452.6117@nanako3.lavabit.com> (Nanako Shiraishi's message of "Fri, 19 Dec 2008 12:44:52 +0900")
Nanako Shiraishi <nanako3@lavabit.com> writes:
> If I understand Alan's case correctly, I think he does not want to
> "undo" the revert but wants to merge an updated version of the branch,
> as if no mistaken merge nor its revert happened in the past.
>
> If you revert the revert on the branch before merging, doesn't it mean
> that you will be merging what the older version of the branch did (that
> is in the revert of the revert as a single huge patch) and what the
> updated version of the branch wants to do? Wouldn't that lead to a mess
> with huge conflicts?
The history immediately after the "revert of the merge" would look like
this:
---o---o---o---M---x---x---W---x
/
---A---B
where A and B are on the side development that was not so good, M is the
merge that brings those premature changes into the mainline, x are
unrelated changes already made on the mainline and W is the "revert of the
merge M" (doesn't W look M upside down?). IOW, "diff W^..W" is similar to
"diff -R M^..M".
I think you misunderstood what "merging an updated version of the branch"
meant by Alan's description to mean that the side branch developers
discarded their faulty A and B, and redone the changes, which would have
resulted in something like:
---o---o---o---M---x---x---W---x---x
\
A'--B'--C'
If that were the situation, suggestion by Linus to revert the revert and
then merge would result in something like this:
---o---o---o---M---x---x---W---x---x---Y---*
\ /
A'--B'--C'
where Y is the revert of W, A' and B'are rerolled A and B, and there may
also be a further fix-up C' on the side branch. "diff Y^..Y" is similar
to "diff -R W^..W" (which in turn means it is similar to "diff M^..M"),
and "diff A'^..C'" by definition would be similar but different from that,
because it is a rerolled series of the earlier change. There would be a
lot of overlap as you feared. In such a case, not having Y (revert of the
revert) would result in a much more trivial merge:
---o---o---o---M---x---x---W---x---x-------*
\ /
A'--B'--C'
because problematic large commits M and W are already outside of the scope
of this final merge.
But I think what Alan's developers did is different. They did this
instead:
---o---o---o---M---x---x---W---x
/
---A---B-------------------C---D
where C and D are to fix what was broken in A and B. In such a situation,
what Linus suggests makes perfect sense. You first revert the revert,
which would result in this:
---o---o---o---M---x---x---W---x---Y
/
---A---B-------------------C---D
where Y is the revert of W, which would (ignoring possible conflicts
between what W and W..Y changed) be equivalent to not having W nor Y at
all in the history:
---o---o---o---M---x---x-------x----
/
---A---B-------------------C---D
and merging the side branch again will not have conflict arising from an
earlier revert and revert of revert.
---o---o---o---M---x---x-------x-------*
/ /
---A---B-------------------C---D
Of course the changes made in C and D still can conflict with what was
done by any of the x, but that is just a normal merge conflict.
To recap, these are two very different scenarios, and wants two very
different resolution strategies:
- If the faulty side branch whose effects were discarded by an earlier
revert of a merge was rebuilt from scratch (i.e. rebasing and fixing,
as you seem to have interpreted), then re-merging the result without
doing anything else fancy would be the right thing to do.
- If the faulty side branch was fixed by adding corrections on top, then
doing a revert of the previous revert would be the right thing to do.
I hope this clears up confusion and fear.
next prev parent reply other threads:[~2008-12-19 8:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-18 23:25 Odd merge behaviour involving reverts Alan
2008-12-18 23:58 ` Linus Torvalds
2008-12-19 0:11 ` Alan
2008-12-19 0:21 ` Linus Torvalds
2008-12-19 0:35 ` Alan
2008-12-19 0:46 ` Linus Torvalds
2008-12-19 1:30 ` Boyd Stephen Smith Jr.
2008-12-19 3:44 ` Nanako Shiraishi
2008-12-19 4:01 ` Linus Torvalds
2008-12-19 4:18 ` Jay Soffian
2008-12-19 4:23 ` Linus Torvalds
2008-12-19 5:24 ` Daniel Barkalow
2008-12-19 8:45 ` Junio C Hamano [this message]
2008-12-19 21:45 ` Nanako Shiraishi
2008-12-19 23:05 ` Junio C Hamano
2008-12-19 23:12 ` Nanako Shiraishi
2008-12-19 23:51 ` Junio C Hamano
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=7vocz8a6zk.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=alan@clueserver.org \
--cc=git@vger.kernel.org \
--cc=nanako3@lavabit.com \
--cc=torvalds@linux-foundation.org \
/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).