Address nightly test failures due to git-diff(1) behaviour change
The nightly tests are failing due to behavioural changes in git-diff(1) introduced in b55e6d36eb (diff: ensure consistent diff behavior with ignore options, 2025-08-08): git@b55e6d36
Gitaly's diffBlob function executes git-diff(1) with the following significant flags:
--patch-with-raw --abbrev=40 --ignore-space-change
-
--patch-with-rawallows us to produce output where the first X lines are diff-format, followed by a newline, followed by the standard patch body. -
--ignore-space-changeis supposed to short-circuit the diff if the only changes are whitespace-related. This is controlled via an RPC option.
There is a breaking change in the output of git-diff(1) with --ignore-space-change present on the next branch.
2.50.1
On Git 2.50.1, invoking git-diff(1) with the same arguments as Gitaly in addition to --no-pager yields:
❯ git --no-pager --git-dir /tmp/gitaly-364529736/292607228/storages.d/default/@hashed/91/46/91468c6323986bf2c002a39f5db53871080bd84d208355d4dc7e78d5f73015c8.git -c gc.auto=0 -c maintenance.auto=0 -c core.autocrlf=false -c core.useReplaceRefs=false -c core.bigFileThreshold=50m -c p
ack.allowPackReuse=multi -c core.fsync=objects,derived-metadata,reference -c core.fsyncMethod=fsync -c core.packedRefsTimeout=10000 -c core.filesRefLockTimeout=1000 -c attr.tree=HEAD diff --patch-with-raw --abbrev=40 --ignore-space-change --end-of-options 257cc5642cb1a054f08cc83f2
d943e56fd3ebe99 564d4ddac63d470827491965b3299872fa67602d
:100644 100644 257cc5642cb1a054f08cc83f2d943e56fd3ebe99 564d4ddac63d470827491965b3299872fa67602d M 257cc5642cb1a054f08cc83f2d943e56fd3ebe99
There is one "raw" line produced which is read by the parser here. The parser continues uneventfully, eventually exiting here.
next
On next, 662b1ed5c5d90a08b6a38b48f842423f2f746b3f, the command yields no output:
❯ /home/jliu/code/git/bin-wrappers/git --no-pager --git-dir /tmp/gitaly-364529736/292607228/storages.d/default/@hashed/91/46/91468c6323986bf2c002a39f5db53871080bd84d208355d4dc7e78d5f73015c8.git -c gc.auto=0 -c maintenance.auto=0 -c core.autocrlf=false -c core.useReplaceRefs=false
-c core.bigFileThreshold=50m -c pack.allowPackReuse=multi -c core.fsync=objects,derived-metadata,reference -c core.fsyncMethod=fsync -c core.packedRefsTimeout=10000 -c core.filesRefLockTimeout=1000 -c attr.tree=HEAD diff --patch-with-raw --abbrev=40 --ignore-space-change --end-of-
options 257cc5642cb1a054f08cc83f2d943e56fd3ebe99 564d4ddac63d470827491965b3299872fa67602d
When it comes time to Parse(), Gitaly finds that no "raw" lines were cached, and the parser exits prematurely with an error.
It seems like we're currently relying on the fact that git-diff(1) with the --ignore-space-change option will produce a diff-format line followed by an empty patch. However, in git@b55e6d36, this behaviour was changed so that no diff-format lines will be produced at all.