KEMBAR78
Merge Editor: Diff Both Inputs Against Each Other · Issue #157496 · microsoft/vscode · GitHub
Skip to content

Merge Editor: Diff Both Inputs Against Each Other #157496

@hediet

Description

@hediet

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
image

with "git.mergeEditor": false on
image

3 way merge editor:
image

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions