Re: [PATCH] git-p4: replace each tab with 8 spaces for consistency
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:00
Phil Hord [off-list ref] 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.