Re: [PATCH] git-p4: replace each tab with 8 spaces for consistency

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] git-p4: replace each tab with 8 spaces for consistency

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:59

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.

Re: [PATCH] git-p4: replace each tab with 8 spaces for consistency

From: Phil Hord <hidden>
Date: 2016-06-15 22:51:00

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help