Re: [PATCH] git-p4: replace each tab with 8 spaces for consistency
- From
Phil Hord <hordp@cisco.com>
- Date
- Apr 7, 2011, 16:35 UTC
- Message-ID
- <4D9DE7E4.1030808@cisco.com>
- In-Reply-To
- <7vhbaafr7r.fsf@alter.siamese.dyndns.org>
On 04/07/2011 03:36 AM, Junio C Hamano wrote:
Show 13 quoted lines
> 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