From: Linus Torvalds <torvalds@linux-foundation.org>
To: Nanako Shiraishi <nanako3@lavabit.com>
Cc: Alan <alan@clueserver.org>, git@vger.kernel.org
Subject: Re: Odd merge behaviour involving reverts
Date: Thu, 18 Dec 2008 20:01:48 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.2.00.0812181949450.14014@localhost.localdomain> (raw)
In-Reply-To: <20081219124452.6117@nanako3.lavabit.com>
On Fri, 19 Dec 2008, Nanako Shiraishi wrote:
>
> 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?
Actually, the reverse is likely true. If the branch you are merging is
actually doing something branch-specific - ie it's a "topic branch", then
it's likely that the new stuff that is on that branch depends on the
previous stuff on the branch.
And thats' the thing that got reverted - so with just a revert, it's quite
likely that you'll get conflicts. But if you revert the revert, now the
new stuff you're merging actually makes more sense, and is less likely to
conflict.
Another way of looking at it is that a merge is something that can be done
both ways: think of the _other_ branch merging yours. The original revert
ends up being a big change-patch that undoes everything that other branch
did, so now if that other branch were to merge the main branch, you'd be
merging a lot of changes. But reverting the revert will undo all those
changes, so again, it's more likely that the merge will succeed.
So revertign a revert is usually going to make subsequent merges easier
rather than the reverse.
The _big_ problem with reverting a whole merge is that it effectively
becomes one commit that does a big change. That's how _normal_ merges tend
to look like in CVS or SVN (ie the "merge" is really just another commit
that brings in a lot of changes), and it's a total and utter f*cking
disaster!
But don't get me wrong - it's not something you can't work with. I'm just
trying to say that it's absolutely not a "good model". It's workable, but
it has all these painful issues.
For example, think about what reverting a merge (and then reverting the
revert) does to bisectability. Ignore the fact that the revert of a revert
is undoing it - just think of it as a "single commit that does a lot".
Because that is what it does.
When you have a problem you are chasing down, and you hit a "revert this
merge", what you're hitting is essentially a single commit that contains
all the changes (but obviously in reverse) of all the commits that got
merged. So it's debugging hell, because now you don't have lots of small
changes that you can try to pinpoint which _part_ of it changes.
But does it all work? Sure it does. You can revert a merge, and from a
purely technical angle, git did it very naturally and had no real
troubles. It just considered it a change from "state before merge" to
"state after merge", and that was it. Nothing complicated, nothing odd,
nothing really dangerous. Git will do it without even thinking about it.
So from a technical angle, there's nothing wrong with reverting a merge,
but from a workflow angle it's something that you generally should try to
avoid.
If at all possible, for example, if you find a problem that got merged
into the main tree, rather than revert the merge, try _really_ hard to
bisect the problem down into the branch you merged, and just fix it, or
try to revert the individual commit that caused it.
Yes, it's more complex, and no, it's not always going to work (sometimes
the answer is: "oops, I really shouldn't have merged it, because it wasn't
ready yet, and I really need to undo _all_ of the merge"). So then you
really should revert the merge, but when you want to re-do the merge, you
now need to do it by reverting the revert.
Linus
next prev parent reply other threads:[~2008-12-19 4:03 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 3:44 ` Nanako Shiraishi
2008-12-19 4:01 ` Linus Torvalds [this message]
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
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
2008-12-19 1:30 ` Boyd Stephen Smith Jr.
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=alpine.LFD.2.00.0812181949450.14014@localhost.localdomain \
--to=torvalds@linux-foundation.org \
--cc=alan@clueserver.org \
--cc=git@vger.kernel.org \
--cc=nanako3@lavabit.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