Currently, we just look at the diffs between input1 and base and input2 and base.
However, if input1 and input2 caused the same edit relative to base, we should be smarter.
By default, git uses the conflict style merge, which diffs the changes against each other and accepts the longest common substring.
Our implementation matches gits diff3 conflict style, which does not move common lines out of conflicts.
Related: #155965
create a new branch conflict
new and commit a file merge_conflict_test.go, with Name: "n1"
// branch conflict
package main
import (
"github.com/gin-gonic/gin"
)
func Foo1(c *gin.Context) {
s1 := s{
ID: 111,
Condition: "c1",
Check: true,
Name: "n1" // diff from master
}
}
func Foo2(c *gin.Context) {
line1 := "line1"
line2 := "line2"
line3 := "line3"
line4 := "line4"
line5 := "line5"
line6 := "line6"
}
func Foo3(c *gin.Context) {
s3 := s{
ID: 123,
Condition: "c3",
Check: true,
Name: "n3" // diff from master
}
}
back to master, also new file merge_conflict_test.go, without Name: "n1"
// branch master
package main
import (
"github.com/gin-gonic/gin"
)
func Foo1(c *gin.Context) {
s1 := s{
ID: 111,
Condition: "c1",
Check: true,
}
}
func Foo2(c *gin.Context) {
line1 := "line1"
line2 := "line2"
line3 := "line3"
line4 := "line4"
line5 := "line5"
line6 := "line6"
}
func Foo3(c *gin.Context) {
s3 := s{
ID: 123,
Condition: "c3",
Check: true,
}
}
commit, then goto conflict, rebase master

with "git.mergeEditor": false on

3 way merge editor:

Originally posted by @Void-king in #157469 (comment)
Currently, we just look at the diffs between input1 and base and input2 and base.
However, if input1 and input2 caused the same edit relative to base, we should be smarter.
By default, git uses the conflict style
merge, which diffs the changes against each other and accepts the longest common substring.Our implementation matches gits
diff3conflict style, which does not move common lines out of conflicts.Related: #155965
create a new branch conflict
new and commit a file merge_conflict_test.go, with Name: "n1"
back to master, also new file merge_conflict_test.go, without Name: "n1"
commit, then goto conflict, rebase master

with "git.mergeEditor": false on

3 way merge editor:

Originally posted by @Void-king in #157469 (comment)