Re: How to fix (and find) many git-* --check errors?

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

Re: How to fix (and find) many git-* --check errors?

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:45:07

"Peter Valdemar Mørch (Lists)"  [off-list ref] writes:
We have > 37000 white space "errors" in HEAD, mostly trailing
whitespace, and I'm looking for a

$ git diff --check | git??? --whitespace=fix

command.
Starting from a clean checkout, you could do something like this:

	$ git reset --hard
        $ rm .git/index
        $ git diff --binary -R HEAD >P.diff
        $ git apply --whitespace=fix --cached <P.diff
	$ git commit -m "Fixed all whitespace gotchas"

P.diff contains essentially everything, and you are recreating everything
from that patch.

Re: How to fix (and find) many git-* --check errors?

From: Peter Valdemar Mørch (Lists) <hidden>
Date: 2016-06-15 22:45:07

Junio C Hamano gitster-at-pobox.com |Lists| wrote:
Starting from a clean checkout, you could do something like this:

	$ git reset --hard
        $ rm .git/index
        $ git diff --binary -R HEAD >P.diff
        $ git apply --whitespace=fix --cached <P.diff
	$ git commit -m "Fixed all whitespace gotchas"

P.diff contains essentially everything, and you are recreating everything
from that patch.
Thanks for taking the time to answer my many mails and questions. It 
really is helpful to me.

Rambling on:

Scary with the "rm .git/index"! It bascially creates an empty index it 
seems... That was news to me. As a newbie I try not to meddle too much 
in .git/ ...

I tried the above on git.git, and it gave:
warning: 485 lines applied after fixing whitespace errors.

I would suggest finishing the above with:
$ git checkout HEAD
otherwise, the working dir is stuck at the old unfixed state.

But like I posted earlier, I have another solution that works on 
selected files. With git, there is always more than one way to do 
things, it seems...

Peter
-- 
Peter Valdemar Mørch
http://www.morch.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help