Magit: Ignore whitespace in diffs

Created on 16 May 2011  路  22Comments  路  Source: magit/magit

It would be nice if we could do something similar to what setting magit-diff-options to '("-w") does in the status buffer, only (a) applied to all diff-showing buffers and (b) not breaking functions that use the diff to generate patches to apply.

feature request

Most helpful comment

You can press D (magit-diff-refresh-popup), set the flags
you want (e.g., -b for --ignore-space-change), and then hit g.

All 22 comments

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

Any one of you is more than welcome to give it a try.

Edit: removed all the "you do it yourself" bullshit and added the following.

I will try to implement this soon.

It won't be as "so good we will never have to touch it again" as I was hoping for. But since this seems important to so many people that probably is not the most important concern at this point :-)

_Tadaaa!_

I have implemented (a233bd4dbfde7aadb171abe0236cd18ac23c2c5b) setting -w as well as other related switches using a popup bound to "h". From the popup these switches can be toggled either for the current buffer only or globally in all magit buffers. The appropriate buffer(s) are automatically updated when exiting the popup.

There is no always visible indicator of the state of these options. I might add that at some point, but for now you have to bring up the popup to see the state.

"h" was previously used for magit-toggle-diff-refine-hunk. That is now bound to "H" instead and also available from inside the popup at "h". We should probably find better keys and reserve "h" for help.

The functionality provided by magit-toggle-diff-refine-hunk could probably be absorbed by the new popup, but that to can wait until a later time.

How do I use this option please?

I am in _magit-status_ buffer, I hit D and..?

If the problem is that you didn't spot the lines -b Ignore whitespace changes (--ignore-space-change) and -w Ignore all whitespace (--ignore-all-space) in the popup, then you now know what to look for.

If the problem is that you don't know how to use the infix arguments in the popup in general, then read the documentation about them: http://magit.vc/manual/magit-popup/Usage.html.

I might be missing something simple, but I can't find any flags or variables (including magit-diff-options, which doesn't exist for me) to toggle whitespace in the status buffer. Is this still supported?

You can press D (magit-diff-refresh-popup), set the flags
you want (e.g., -b for --ignore-space-change), and then hit g.

@tarsius Is there a way to use these flags when viewing commits? In magit-log when I select a commit I can use magit-diff-toggle-refine-hunk to get a word-wise diff, but there seems to be no way to set -w. If in contrast I use d -w d to view a commit, I can ignore whitespace. It would be great if this (and other diff options?) could be toggled also for the default commit view.

@chaoflow magit-diff-refresh-popup (now named magit-diff-refresh) is available from magit-revision-mode buffers as well.

@kyleam Thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings