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

Merging adjacent deleted lines?

From
Jonathan del Strother <maillist@steelskies.com>
Date
Jan 21, 2009, 19:20 UTC
Message-ID
<57518fd10901211120n62f8d0e9ya8595fc9baa6476c@mail.gmail.com>
Say I have a file that started out with the following content :

line1 line2 line3 line4

I create a branch, which deletes line2.  Someone else's branch deletes line 3.
When I merge those two branches, the conflict looks like :

line1 <<<<<<< HEAD:lines line3 ======= line2

>>>>>>> SomeoneElse:lines
line4

Which in my cursory overview, looked an awful lot like the obvious merge resolution ought to be

line1 line3 line4

After all - I know I want to delete line 2, and wasn't aware of the other person deleting line 3.

It was only later that we discovered that the merge was broken and both lines should have been deleted. Thinking about it, I guess that the conflict if the other branch _hadn't_ deleted line 3 would have looked something like

line1 <<<<<<< HEAD:lines ======= line2

>>>>>>> SomeoneElse:lines

line3 line4

 - which wouldn't have resulted in a conflict anyway.

So, it looks like I need to be way more careful when merging conflicts. Which leads me to - what tools do you use when studying conflicts like that? git blame seems the obvious one, for getting the context of each deletion, but it seems like I need to run it once as git blame HEAD lines, and once as git blame MERGE_HEAD lines. Is there something a little more integrated for comparing the origin of each change from both merge branches simultaneously?

Would welcome any thoughts on how you guys approach conflict-resolution -Jon

Next: Robin Rosenberg
Message 1 of 9 in “Merging adjacent deleted lines?”
  1. Jonathan del StrotherJan 21, 2009
  2. Robin RosenbergJan 21, 2009
  3. Junio C HamanoJan 21, 2009
  4. Jonathan del StrotherJan 22, 2009
  5. Robin RosenbergJan 22, 2009
  6. Jay SoffianJan 23, 2009
  7. Robin RosenbergJan 23, 2009
  8. Jay SoffianJan 23, 2009
  9. Jay SoffianJan 23, 2009

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.