Skip to content

x/tools/internal/diff: non-minimal diff #59232

@adonovan

Description

@adonovan

The x/tools diff algorithm reports correct but non-minimal diffs even for the trivial case where a new line is inserted in the middle of a two-line file. For example:

	got := "aaa\nccc\n"
	want := "aaa\nbbb\nccc\n"
	delta := diff.Unified("got", "want", got, want)

GNU diff -u:

--- want
+++ got
@@ -1,2 +1,3 @@
 aaa
+bbb
 ccc

diff.Unified:

--- got
+++ want
@@ -1,2 +1,3 @@
-aaa
+aaa
+bbb
 ccc

We should match the GNU diff behavior in cases this simple.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions