]> Cypherpunks repositories - gostls13.git/commit
internal/diff: add, replacing cmd/internal/diff
authorRuss Cox <rsc@golang.org>
Sat, 29 Jan 2022 21:13:12 +0000 (16:13 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 18 Mar 2022 16:56:29 +0000 (16:56 +0000)
commit7747c33a41491be74da65b116718f4df7a2f8337
tree5dc2a332865fe954703f5e05dc62e670a7732d4c
parent8ff42d1bb1919b38e0d852618168f18d33db866b
internal/diff: add, replacing cmd/internal/diff

This is an in-process (non-exec'ing) replacement for cmd/internal/diff.
It uses an O(n log n) algorithm instead of the O(n²) algorithm
in standard diff binaries. It does not produce the absolute
shortest diffs, but the results are often more meaningful
than the standard diff, because it doesn't try to align
random blank lines or other noise.

Adding so that tests inside std (especially go/printer)
can print diffs.

Replacing cmd/internal/diff because we don't need two.

Change-Id: I9155dd925e4a813f5bfa84a8ad3dec8ffdbf8550
Reviewed-on: https://go-review.googlesource.com/c/go/+/384255
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>
21 files changed:
src/cmd/fix/main.go
src/cmd/fix/main_test.go
src/cmd/gofmt/gofmt.go
src/cmd/gofmt/gofmt_test.go
src/cmd/internal/diff/diff.go [deleted file]
src/go/build/deps_test.go
src/go/printer/printer_test.go
src/internal/diff/diff.go [new file with mode: 0644]
src/internal/diff/diff_test.go [new file with mode: 0644]
src/internal/diff/testdata/allnew.txt [new file with mode: 0644]
src/internal/diff/testdata/allold.txt [new file with mode: 0644]
src/internal/diff/testdata/basic.txt [new file with mode: 0644]
src/internal/diff/testdata/dups.txt [new file with mode: 0644]
src/internal/diff/testdata/end.txt [new file with mode: 0644]
src/internal/diff/testdata/eof.txt [new file with mode: 0644]
src/internal/diff/testdata/eof1.txt [new file with mode: 0644]
src/internal/diff/testdata/eof2.txt [new file with mode: 0644]
src/internal/diff/testdata/long.txt [new file with mode: 0644]
src/internal/diff/testdata/same.txt [new file with mode: 0644]
src/internal/diff/testdata/start.txt [new file with mode: 0644]
src/internal/diff/testdata/triv.txt [new file with mode: 0644]