git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Odd merge behaviour involving reverts

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Dec 19, 2008, 05:24 UTC
Message-ID
<alpine.LNX.1.00.0812182353490.19665@iabervon.org>
In-Reply-To
<alpine.LFD.2.00.0812181949450.14014@localhost.localdomain>
On Thu, 18 Dec 2008, Linus Torvalds wrote:
Show 33 quoted lines
> 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!

Another option is to do the big revert on the master branch, and on the side branch merge the parent of the revert (normally), and then merge the revert but take the side branch tree.

That last merge puts the revert in the branch's history, but rejects its effects. Now merging the branch again will find the revert to be the common ancestor, and see the full change of the side branch as the contribution of that side. Also, blame will come down the side branch, ignore the merge (on the side branch, the merge contributed no content changes), and go into the original side branch commits.

You can also think of it as the side branch saying, "I noticed that you reverted my changes, but I'm keeping them anyway". When the final merge comes, git will see that the revert isn't new information to the side branch, and nullify its effect. (Of course, the side branch needs to merge the parent of the revert so that it isn't rejecting the other changes made on the main branch before the revert)

	-Daniel
*This .sig left intentionally blank*
Previous: Linus TorvaldsNext: Junio C Hamano
Message 11 of 17 in “Odd merge behaviour involving reverts”
  1. AlanDec 18, 2008
  2. Linus TorvaldsDec 18, 2008
  3. AlanDec 19, 2008
  4. Linus TorvaldsDec 19, 2008
  5. AlanDec 19, 2008
  6. Linus TorvaldsDec 19, 2008
  7. Nanako ShiraishiDec 19, 2008
  8. Linus TorvaldsDec 19, 2008
  9. Jay SoffianDec 19, 2008
  10. Linus TorvaldsDec 19, 2008
  11. Daniel BarkalowDec 19, 2008
  12. Junio C HamanoDec 19, 2008
  13. Nanako ShiraishiDec 19, 2008
  14. Junio C HamanoDec 19, 2008
  15. Nanako ShiraishiDec 19, 2008
  16. Junio C HamanoDec 19, 2008
  17. Boyd Stephen Smith Jr.Dec 19, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.