Re: git merge bug report

Lucas Seiki Oshiro
2025-04-15T14:13:52Z

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.