Add support for Apple Diff.
Review Request #12647 — Created Sept. 26, 2022 and submitted — Latest diff uploaded
Starting in macOS Ventura, the
diff
command will be Apple Diff instead
of GNU Diff. This is based on BSD Diff with some GNU Diff
compatibility in the form of function arguments and general Unified Diff
output, but with minor differences in output.This change implements the Apple Diff backend. It is very similar to the
GNU Diff backend, but without any instructions if missing (as Apple Diff
isn't something you'd install separately), and with some normalization
for output.Normalization ensures that the timestamps are the same between Apple
Diff and GNU Diff. In GNU Diff, file timestamps have millisecond
precision and show the timezone offset. Apple Diff lacks both. This is
documented in the man page, and they state that running in legacy mode
(by settingCOMMAND_MODE=legacy
) will restore milliseconds and
timezone offsets. Rather than trust that legacy mode will exist
long-term, we handle normalization through our own process,
future-proofing to avoid problems if that behavior reverts back to GNU
Diff behavior.They do note that millisecond precision and timezone offsets may cause
patches to fail to apply, but that doesn't appear to happen locally and
that would be a wider compatibility problem in the diff world anyway,
requiring normalization on the other end.All clients that require an external diff tool have been updated to work
with Apple Diff. A notable client is TFS, which may generate a diff by
going directly through GNU Diff by way ofrb-tfs
, but it should still
be compatible.
All unit tests pass on a system with GNU Diff and on one with
Apple Diff.