gitwinmerge

WinMerge - ignore all whitespace including newlines and formatting changes


How can I ignore "code style" changes while using WinMerge as a difftool? Specifically across two commits.

So that

thing
{
  a,
  b
}

and

thing { a, b }

would be treated as identical.

Essentially this question, but for winmerge rather than diff.

.gitconfig:

[diff]
    tool = winmerge
[difftool]
    prompt = false
[difftool "winmerge"]
    cmd = "$HOME/scripts/winmerge.sh" "$LOCAL" "$REMOTE"
[mergetool]
    prompt = false
    keepBackup = false
    keepTemporaries = false
[merge]
    tool = winmerge
[mergetool "winmerge"]
    cmd = "'C:/Program Files (x86)/WinMerge/WinMergeU.exe'" -e -u -fm -dl \"Local\" -dr \"Remote\" "$LOCAL" "$MERGED" "$REMOTE"

(winmerge.sh just calls WinMergeU.exe -e -u -wr "$1" "$2")

None of the command line options seem to fit, and I think line filters won't work because they are per-line.


Solution

  • To answer my own question with the benefit of more time:

    Not-quite-there solutions:

    Ignore blank lines; Ignore carriage return differences (Windows/Unix/Mac)

    This ignores line feed differences, and full blank line differences, but does not compare files semantically. It does help in certain simple cases.

    Line filter ^\s*$

    Same as "Ignore blank lines"

    .gitattributes formatter with textconv for specific file types

    This is the closest option for read-only diffs, with the downsides of:

    My current solution