Skip to content

Conversation

gerhardol
Copy link
Member

@gerhardol gerhardol commented May 3, 2024

Tweak to #11674

Proposed changes

git-diff detects moved blocks (with at least 20 chars) and colors adjacent blocks with alternate colors.
The alternative color profile will use dimmed colors for lines that are moved without changes so changed lines stand out better.
Border lines close to changes are marked (not always done by Git though...)

A better description: https://stackoverflow.com/questions/57817642/whats-the-purpose-of-dimmed-zebra

This PR changes to use dimmed-zebra instead (zebra is git default).
A bonus is that the GE colors are hard to see in the terminal. (such theme colors are hard to tune)
After feedback, colors are changed to be dimmed colors for moved and normal colors (but not reverse video) for border lines.

Need to be updated in the GE doc PR too.

Screenshots

Before

block1 and block2 should have alternate colors

image

After

Not sure why block2 added do not have alternate colors

image

Slight update with some alternate blocks where border is seen

image

Test methodology

manual

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@mstv
Copy link
Member

mstv commented May 5, 2024

I agree that the colors from undimmed zebra are very / too bright for GE.
With dimmed-zebra, moved lines often are displayed as gray text at the new position. This feels misleading to me. Can this color mapping be adapted?

@gerhardol
Copy link
Member Author

gerhardol commented May 5, 2024

I agree that the colors from undimmed zebra are very / too bright for GE.

Colors are are selected from a bright theme with weighted values:
https://github.com/gitextensions/gitextensions/blob/master/GitUI/Editor/Diff/AnsiEscapeUtilities.cs#L372
Adjusting ahould be done to all colors if done.
(A better "theme" to use? Mintty translates colors depending on the context where they are used too.)

With dimmed-zebra, moved lines often are displayed as gray text at the new position. This feels misleading to me. Can this color mapping be adapted?

The "slots" that can be configured:
https://git-scm.com/docs/git-config#Documentation/git-config.txt-colordiffltslotgt
The default values (see name of the slot a few lines below)
https://github.com/git/git/blob/master/diff.c#L75
Translation to colors
https://github.com/git/git/blob/master/color.c#L24

dimmed-zebra applies faint/dim to first section and dim-italics to alternative. They will therefore look the same (similar in mintty when I test). I do not know if the intention in Git is to have default color dim (and possibly italic). In all cases the color is reset so magenta etc is not applied.
In some way, dimmed-zebra is a theme. The colors close to "borders" are not dimmed so that can be easier to see still.

One alternative is to override the bold colors for moved in zebra (and bold in range-diff) from bold to normal (or maybe dim).
Block detection is "random" and can differ zebra and dimmed-zebra. Someone should report a Git issue.

image

image

Will update the PR, change the title.

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

gerhardol added a commit to gerhardol/gitextensions that referenced this pull request May 6, 2024
Dimmed-colors put emphasis on the border between changes.

Override diff moved colors
Default (zebra) use bold colors that are too bright,
dimmed-zebra by default only gray.
Usea combination with dimmed colors for moved lines and normal
colors for border changes.

Bold/bright changed to normal also for range-diff
@gerhardol gerhardol force-pushed the feature/dimmed-zebra branch from 75f9ea6 to 1fd0715 Compare May 6, 2024 20:06
Dimmed-colors put emphasis on the border between changes.

Override diff moved colors
Default (zebra) use bold colors that are too bright,
dimmed-zebra by default only gray.
Usea combination with dimmed colors for moved lines and normal
colors for border changes.

Bold/bright changed to normal also for range-diff
@gerhardol gerhardol force-pushed the feature/dimmed-zebra branch from 1fd0715 to b4e5758 Compare May 7, 2024 20:37
@gerhardol
Copy link
Member Author

I made the range-diff specific not being printed, the command is long enough as it is (not important to optimize for range-diff).
A little too much override but much easier than adjusting the bold colors.

@gerhardol gerhardol merged commit e0f004c into gitextensions:master May 7, 2024
@gerhardol gerhardol deleted the feature/dimmed-zebra branch May 7, 2024 21:33
@RussKie RussKie added this to the vNext milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants