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

Re: Merge seems to get confused by (reverted) cherry-picks

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Sep 3, 2008, 08:37 UTC
Message-ID
<20080903083739.GA18653@atjola.homenet>
In-Reply-To
<7vprnld5ws.fsf@gitster.siamese.dyndns.org>
On 2008.09.03 00:50:43 -0700, Junio C Hamano wrote:
Show 25 quoted lines
> But in 3-way merge context, you do not interpret the fact that something
> is identical between 0..2 as "they MUST STAY THE SAME".  Instead, you read
> it as "My history does not care what happens to that path -- if the other
> guy wants to change it, I'll happily take it."
> 
>     Note.  I am not claiming that the above interpretation will always
>     match what you would expect.  I am just explaining how the underlying
>     concept of 3-way merge works in general.  If you think about it in a
>     realistic context, such as the "extern in xyzzy.h you did not need to
>     add but the other guy needed to have", you'll realize that more often
>     than not, "I do not care and let the other guy decide" interpretation
>     results in a more useful result.
> 
> That essentially boils down to three rules:
> 
>  (0) If both of you did not change anything, the final result won't have
>      any change (obvious);
> 
>  (1) If you decided you do not have a need to change a path, but the other
>      one saw a need, you take the change;
> 
>  (2) If you and the other one both wanted to change a path but in a
>      different way, you need to merge at the contents level.
> 
> And you are seeing rule (1) in action.

OK, so that basically means "if you cherry-pick, you better make sure that you don't have to revert or just get your fine-toothed comb ready when you merge later", right? Any advice on how to deal with such a situation?

The actual use case I had was somewhat like this: Some new code got added in commit A on the master branch as it was intended for the next major release. Then it became obvious that it needs to go into a minor release, so it got cherry-picked into the maintainance branch. For some reason that new code then got moved into a different file. That move happened on the maintainance branch (ie. immediate bugfix). And then came the regular merge of the maintainance branch into the master branch, which ended up with the code being duplicated.

(Well, actually, it's a two-level maintainance branch setup, but you get the idea...)

Of course, in a perfect world the first commit would never have been cherry-picked and would've been originally made on the maintainance branch, and the problem would have never shown up. But that's not the case and I'm not omniscient, so I would have surely missed the problem, if it wasn't for that two-level setup, which for this merge meant that the merge result should have been equal to the branch being merged, so it was easy to spot.

Björn
Previous: Junio C HamanoNext: Linus Torvalds
Message 4 of 9 in “Merge seems to get confused by (reverted) cherry-picks”
  1. Björn SteinbrinkSep 3, 2008
  2. Björn SteinbrinkSep 3, 2008
  3. Junio C HamanoSep 3, 2008
  4. Björn SteinbrinkSep 3, 2008
  5. Linus TorvaldsSep 3, 2008
  6. Ittay DrorSep 3, 2008
  7. Andreas EricssonSep 3, 2008
  8. Johan HerlandSep 3, 2008
  9. Mike HommeySep 3, 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.