Skip to content

Teach git diff --color-words to be helpful when there are merge conflicts #386

Open
@dscho

Description

@dscho

Note: this project is technically challenging, as it touches two complex parts of Git's code: the diff machinery and the staging area/worktree with conflicts.

The --color-words option allows visualizing differences between two file versions on a word-level (rather than a line-level).

Currently, the --color-words option is totally ignored when visualizing merge conflicts in a worktree. All conflicted lines, including the conflict markers, are marked in green, as if the --color-words option had not been present at all.

A much more useful thing to do would be to build temporary buffers from the two sides of each conflict and then present the color diff of those buffers (the first side with an implied --reverse).

In case that it is a diff3 style conflict, there are three sides in each merge conflict (the "middle" one being the base), so the first side could show a --color-words diff between base and the first side, and the last side could equally show a --color-words diff between base and the last side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions