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

Re: git merge bug report

From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Date
Apr 15, 2025, 14:13 UTC
Message-ID
<39551FA4-855C-4E55-BC2B-F77D9BBCCF6A@gmail.com>
In-Reply-To
<CAE8aReXOwM8ByyObxrb8NhRMYfK1OB_6B9eOO07mYXMkp_E8EA@mail.gmail.com>
Hi!
> I would like to report a bug I encountered in Git during a merge
> operation. The method from one branch was merged into the wrong class,
> despite there being no reported conflict.
Thanks for your script! I could reproduce this here!

When two branches changes the same plaintext file, Git tries to merge them based on their contents without taking into account the syntax. It is done using diff algorithms, which you can change using `-X diff-algorithm=<algorithm>`.

I tried the four algorithms available (minimal, histogram, myers and patience) and all of them produced the same result.

Sadly, they are not infallible and those mistakes may happen. There are other cases where it can happen. For example, imagine a Python class with only two methods and each branch deletes one of them. After merging, it will leave an empty class definition, which is not allowed in Python (unless you use `pass`). These algorithms are not aware of that, and they'll leave an invalid Python file.

Also note that they are not exactly wrong. They only do their work naively based on the information they have.

This way, it's always a good idea to check if the merge went well.
Previous: Junio C HamanoNext: mu gsh
Message 3 of 4 in “git merge bug report”
  1. mu gshApr 15, 2025
  2. Junio C HamanoApr 15, 2025
  3. Lucas Seiki OshiroApr 15, 2025
  4. mu gshApr 15, 2025

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.