public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* git merge bug report
@ 2025-04-15 12:23 mu gsh
  2025-04-15 13:52 ` Junio C Hamano
  2025-04-15 14:13 ` Lucas Seiki Oshiro
  0 siblings, 2 replies; 4+ messages in thread
From: mu gsh @ 2025-04-15 12:23 UTC (permalink / raw)
  To: git

Dear Git Maintainers,

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.

Git Version: git version 2.49.0
Operating System: Arch Linux

Description:
When merging two commits involving changes to the same file, Git does
not report a conflict, but the resulting merged file places a method
in an unexpected class. This seems like a mismerge.


Steps to Reproduce
You can reproduce the issue using the following shell script:
```
#!/bin/bash

set -e

# init in /tmp dir
rm -rf /tmp/git-merge-bug
mkdir -p /tmp/git-merge-bug && cd /tmp/git-merge-bug
git init
cat > models.py <<EOF
class User:
    name = "str"


class Product:
    id = 0
EOF
git add models.py
git commit -m "initial: User and Product class"

# feature1
git checkout -b feature
cat > models.py <<EOF
class User:
    name = "str"

    def user_method(self):
        return


class Product:
    id = 0
EOF
git commit -am "feature: add method to User"

# feature 2
git checkout master
cat > models.py <<EOF
class User:
    name = "str"
    bugger = "fix me"


class NoMethod:
    pass


class Product:
    id = 0
EOF
git commit -am "master: add field to User and new class"

git merge feature
echo
echo "==== merged, user_method into NoMethod class  ===="
cat models.py
```

Actual Result

After the merge, the user_method ends up inside the NoMethod class,
which is incorrect and unexpected.


Please let me know if any additional information is needed. Thank you
for your time and help.


Best regards,

gshmu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-15 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-04-15 16:20   ` mu gsh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox