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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Phil Hord <hordp@xxxxxxxxx> writes:

> 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.

If you understood the example I gave, you should be able to figure all of
these out.  In the most general case, you would come up with a way to
generate a diff that represents the change you want to fix (e.g. "new
errors" would be comparing the HEAD and the working tree), reverse apply
the diff and then forward apply the same diff with --whitespace=fix, but
often you can omit "reverse apply the diff" step by finding an appropriate
combination between HEAD/index/working tree.

I long time wrote this alias

[alias]
        wsadd = "!sh -c 'git diff -- \"$@\" | git apply --cached --whitespace=fix;\
                git co -- ${1-.} \"$@\"' -"

that acts as if you are saying "git add $path" while fixing the whitespace
errors I introduced in the working tree version.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]