Andrew Garber [off-list ref] writes:
Note that the majority of git-p4 uses spaces, not tabs, for indentation.
Consistent indentation is critical to the functionality of Python
scripts: mixing tabs and spaces in Python can lead to hard-to-find bugs.
Mixing tabs and spaces can lead to hard-to-find bugs, I agree.
I just threw this in to my .git/info/attributes:
contrib/fast-import/git-p4 whitespace=!indent,tail,tab-in-indent
and then did this:
$ >contrib/fast-import/git-p4
$ git diff -R | git apply --whitespace=fix
$ git diff
The changes I get out of the last step seem to exactly match your patch.
Thanks.
On 04/07/2011 03:36 AM, Junio C Hamano wrote:
Mixing tabs and spaces can lead to hard-to-find bugs, I agree.
I just threw this in to my .git/info/attributes:
contrib/fast-import/git-p4 whitespace=!indent,tail,tab-in-indent
and then did this:
$ >contrib/fast-import/git-p4
$ git diff -R | git apply --whitespace=fix
$ git diff
The changes I get out of the last step seem to exactly match your patch.
Junio! Thanks for that recipe.
I suspected there must be some way to employ git-apply's whitespace=fix
feature to ws-normalize my code, but I was clueless how to do that. I
wound up cobbling together a python script that reimplements the same
fixes (hopefully).
I wish this (the git-apply trick) was documented somewhere and/or made
more prominent. Is it, and I have also overlooked it?
This is what I want:
git fix-whitespace # fix new ws errors in workdir
git fix-whitespace --all # fix all ws errors in workdir
git fix-whitespace foo # fix new ws errors since foo
git fix-whitespace --cached # fix new ws errors in the index
etc.
Is this already implemented somewhere in the git porcelain?
Phil