Closed blueyed closed 7 years ago
I've also found that additionally --diff-algorithm=patience
makes the diff more useful in general.
But since this can be configured per project, or globally (git config --global diff.algorithm patience
) it should not be added here probably.
I came up with a patch for Git in the end: https://public-inbox.org/git/20170623103612.4694-1-git@thequod.de/T/#u
The
-U0
withgit-diff
(to have no context lines) causes the hunk to be off / not aligned as well as without-U0
(where 3 is the default). Using-U1
already fixes this.This typically happens when a block of text is added, where only e.g. the function name / title is adjusted: with
-U0
the diff will not start at the new block, but before already.It looks like the context is not only used for display in git-diff, but also has an impact on the detection:
xecfg.ctxlen
is set according to-U
: https://github.com/git/git/blob/05ec6e13aaf33b6a647e1321203a770e697eea9a/diff.c#L2525-L2528trim_common_tail
is called for 0-context, and if--function-context
is not used: https://github.com/git/git/blob/05ec6e13aaf33b6a647e1321203a770e697eea9a/xdiff-interface.c#L134-L135git version 2.13.1.
Since using
--function-context
adds extra processing, I suggest to use-U1
instead of-U0
.