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

Re: git merge bug report

From
MGmu 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:
    pass

class 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.
Previous: Lucas Seiki Oshiro
Message 4 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.