Re: git merge bug report
- From
- mu gsh <yue937@gmail.com>
- Date
- Apr 15, 2025, 16:20 UTC
- Message-ID
- <CAE8aReUm2rCR76L2T175Ng5Pir+-G_a4whxiOPhfvNzXSV_d2Q@mail.gmail.com>
- In-Reply-To
- <39551FA4-855C-4E55-BC2B-F77D9BBCCF6A@gmail.com>
Hi!
focus on the feature 2, the two double empty lines, which one is the new one?
```
bugger = "fix: the empty lines blow not the new added lines"class NoMethod:
passclass Product ```
Should the second one be newly added? instead of the first
On Tue, 15 Apr 2025 at 22:13, Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> wrote:
Show 28 quoted lines
> > 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.