public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
To: mu gsh <yue937@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git merge bug report
Date: Tue, 15 Apr 2025 11:13:35 -0300	[thread overview]
Message-ID: <39551FA4-855C-4E55-BC2B-F77D9BBCCF6A@gmail.com> (raw)
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.

  parent reply	other threads:[~2025-04-15 14:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 12:23 git merge bug report mu gsh
2025-04-15 13:52 ` Junio C Hamano
2025-04-15 14:13 ` Lucas Seiki Oshiro [this message]
2025-04-15 16:20   ` mu gsh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39551FA4-855C-4E55-BC2B-F77D9BBCCF6A@gmail.com \
    --to=lucasseikioshiro@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=yue937@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox