开发者

Separate Whitespace Patches from Non-Whitespace Patches

Does anyone know of a way or a script that given a patch file can separate the whitespace changes from the functional changes?

Here's the issue. My project has strict whitespace style requirements and I have my editor set to enforce them. No tabs, No trailing spaces. My editor is set to automatically strip traiing spaces for example.

So, what inevitably happens is it's all good until I edit some third party code. I forget to turn off those oh-so-convenient features and then I get bitching from devs that the whitespace changes need to separated from the functional changes. So, 6 hours of editing code all has to get hand redone. No wonder so many bugs and features go unfixed when devs are more interested in 'rules' than 'results'. Okay, eno开发者_如何学JAVAugh bitching.

Ideally I'd just run some script that would remove all whitespace changes from the patch and be done. Anyone know of such a feature?


Keep a copy of the original file, apply the patch and then diff again - this time with whitespace changes ignored:

$ diff -u --ignore-all-space orig-file file > patch

Now, apply the patch to orig-file and diff again, with whitespaces enabled - and you have the 2nd patch with only whitespace changes.

Git

With git, it's a bit easier:

$ git diff -w > patch
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜