Reputation: 5736
Not sure if this is in general the git thing or gitlab, but I don't like it highlighted a rather long sub-section of a long continuous string in deeper colour including parts that were not changed when only some characters are changed in the string.
Is there a way to configure gitlab not to do this? i.e. just highlights those characters updated only
e.g. this is what I got on gitlab 8.10
and I expect it to hightlight only the '2' between 't' and 'i' and highlight the 'g' between 'm' and 'a'
Upvotes: 1
Views: 1194
Reputation: 4650
This feature was introduced in Gitlab 8.10 (see section "Inline Diffs").
git
itself uses line-based diffs, so it will internally always store the complete changed lines. However, git tools also allow to visually highlight only those changed parts, e.g. with git diff --word-diff=color
.
Edit
What Gitlab 8.10 introduces are additional highlights in changed lines. I.e. the complete changed lines will be highlighted with a light green/red, and the actual changes within a line will be highlighted with a darker green/red. This is what you see in your figure:
and in the figure of Gitlab's release notes:
Apparently, Gitlab highlights the largest part of the line that contains any changes. It does not try to produce minimal changes, probably due to performance reasons.
The git --word-diff=color
option (including gitk
's Markup words
and Color words
setting) do produce fewer highlights. Compare Gitlab's diff:
with the same diff from gitk
:
However, even --word-diff=color
will—as the name suggests—only highlight on a word-by-word basis. For your example, it will simply highlight both words. Here is your case reproduced in gitk
with Color words
:
For the command line tools (e.g. git diff
), there is actually an option --color-words=.
that will do what you want:
However, neither gitk
nor Gitlab know this option, as far as I know.
Upvotes: 3