Reputation: 3247
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.
Upvotes: 18
Views: 27367
Reputation: 1
While it is not possible in winmerge, Emacs does it easily.
In 'ediff' mode you can press '#' key twice in the control panel (it is read as a command). It will ignore line break differences altogether.
Emacs is a wonderful editing environment but, unfortunately, its ediff-mode is not a very user friendly tool. The control panel is in a different window which is a bit confusing. See the final part of the youtube tutorial below for a tweak that puts the control panel in the main window.
Read more:
https://www.gnu.org/software/emacs/manual/html_mono/ediff.html
https://www.youtube.com/watch?v=pSvsAutseO0
Upvotes: 0
Reputation: 753
These options work for me:
WinMerge -> Edit -> Options -> Compare -> General ->
The answer was taken from https://superuser.com/questions/174275/can-i-compare-only-file-contents
Upvotes: 23
Reputation: 4484
One aspect of the issue is indent, which may vary between spaces and tabs, or just may be different. Using the replacement filters in WinMerge whis is easy to solve.
(found in tools -> filter, use a single space in the "replace by" column)
Unfortunately, [\s\r\n]
won't work in the replacement filter to take care of newlines. This is probably an issue of performance.
Upvotes: 0
Reputation: 3247
To answer my own question with the benefit of more time:
difftastic
does this for read-only diffs at the cost of speed and memoryIgnore 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 withtextconv
for specific file types
This is the closest option for read-only diffs, with the downsides of:
difftastic
is slow or hogging memory, fall back to diff
/WinMerge/VSCodeUpvotes: 1
Reputation: 327
In addition of ignoring white spaces/blank lines/...etc. Do the following
-Refresh the comparison
Upvotes: 0
Reputation: 4686
You could add a .gitattributes
for your file. This would run a tool to normalize/beautify/prettify both files before comparison.
This will run .json
files through json_pp
before compare:
echo "*.json diff=json" >> .gitattributes
git config diff.json.textconv json_pp
Check out git documentation for details: https://git-scm.com/docs/gitattributes
Source: https://t-a-w.blogspot.com/2016/05/sensible-git-diff-for-json-files.html
Upvotes: 0