Repository navigation
loopvec: label -d diffs with the file's path - #10
Merged
Merged
Conversation
-d ran diff -u on two temporary files and replaced their names with the file's path, so each header still carried diff's timestamp. GNU diff prints it as "2026-10-31 18:49:17.123456789 +0000" and BSD diff, the one macOS ships, as "2026-10-31 18:49:17", which made flag_diff.txt fail on macOS, and the timestamp of a temporary file says nothing about the source. diff now labels both sides with the path (-L, which GNU and BSD diff both support), as gofmt -d does, so the headers are the same everywhere.
thesyncim
force-pushed
the
diff-labels
branch
from
November 1, 2026 13:36
ca47d57 to
a687925
Compare
mauri870
enabled auto-merge (squash)
November 3, 2026 20:34
mauri870
added a commit
that referenced
this pull request
Nov 3, 2026
`printDiff` wrote both sources to temporary files and ran the system `diff`. That made `-d` depend on the host. Windows has no `diff`. GNU and BSD diff printed different headers until #10 labeled them. And the error was ignored, so a missing or failing `diff` printed nothing while loopvec still exited 0. This change computes the unified diff in process with [github.com/pmezard/go-difflib](https://github.com/pmezard/go-difflib) (BSD-3, about 1,300 importing packages, mostly through testify). The labels stay the same, with both sides named after the file path and three lines of context. The temporary files and the `exec` call are gone. The library's own `SplitLines` adds an empty line after a final newline, which would show up as a context line past the end of the file, so `printDiff` splits the lines itself. go-difflib can align a hunk differently from GNU diff. For example, it may put an added line on the other side of an unchanged blank line or `}`. The patches still apply the same way. I checked this by running `loopvec -d std` with the old and new code: all 17 files that get a diff apply with `patch -F0` and give exactly the same source as GNU diff's patches. Since the output no longer depends on the machine, `flag_diff.txt` now checks it whole instead of line by line. Its patch also applies with `patch -F0`. `make ci` passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
flag_diff.txtfails on macOS. The-dheaders carrydiff's timestamp, and BSD diff prints it differently from GNU diff (no fractional seconds, no zone). It's the timestamp of a temp file anyway, so it doesn't tell the reader anything.This passes
-L pathfor both sides (GNU, BSD and busybox diff all have it), so the headers are just--- path/+++ pathlikegofmt -d, and the filename replacement goes away. The four diff scripts now expect the path alone.It's one of three small fixes to get the suite passing on macOS, along with #8 and #9, which I needed while trying loopvec on goav1.