eclipse-jgit / jgit

JGit, the Java implementation of git
https://www.eclipse.org/jgit/
Other
92 stars 31 forks source link

Incorrect merge conflict in diff3 style #38

Closed wetneb closed 3 months ago

wetneb commented 4 months ago

Version

6.9.0.202403050737-r

Operating System

Linux/Unix, MacOS, Windows

Bug description

The jgit library produces invalid conflicts when using the "diff3" style. Consider the following example:

Ours

a
d

Base

a
b
d

Theirs

a
b
c
d

In other words, ours deletes the b line and theirs keeps it but inserts the c line after it.

Actual behavior

The merged result is

a
<<<<<<< OURS
||||||| BASE
b
d
=======
b
c
>>>>>>> THEIRS
d

(note the incorrect inclusion of the d in the base part of the conflict hunk, duplicating the d outside of the conflict)

Expected behavior

The merged result should be

a
<<<<<<< OURS
||||||| BASE
b
=======
b
c
>>>>>>> THEIRS
d

Relevant log output

No response

Other information

No response