git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Whitespace on commit
@ 2008-03-13  3:38 Kenneth P. Turvey
  2008-03-13  3:52 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Kenneth P. Turvey @ 2008-03-13  3:38 UTC (permalink / raw)
  To: git

I keep getting annoying errors when I try to commit.  Git complains that I
have whitespace in the wrong places.  

This is fine.. I even like it.  What I don't like is having to change this
stuff manually.  Is there anyway to tell git to just fix the stuff and do
the commit?  

I've tried setting

apply.whitespace = fix 

in my .gitconfig, but that doesn't seem to help when doing commits.  Is
there another way to handle this? 

Thanks!

-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Whitespace on commit
  2008-03-13  3:38 Whitespace on commit Kenneth P. Turvey
@ 2008-03-13  3:52 ` Junio C Hamano
  2008-03-13  7:34   ` Andreas Ericsson
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2008-03-13  3:52 UTC (permalink / raw)
  To: Kenneth P. Turvey; +Cc: git

"Kenneth P. Turvey" <kt-usenet@squeakydolphin.com> writes:

> I keep getting annoying errors when I try to commit.  Git complains that I
> have whitespace in the wrong places.  
>
> This is fine.. I even like it.  What I don't like is having to change this
> stuff manually.  Is there anyway to tell git to just fix the stuff and do
> the commit?  
>
> I've tried setting
>
> apply.whitespace = fix 
>
> in my .gitconfig, but that doesn't seem to help when doing commits.

Yeah, that is to protect yourself from whitespace mess _other people_
threw at you in a patch form.

You can ask git to fix your own stuff up, by pretending that you are that
other person who made the mess, by doing:

	git diff HEAD >P.diff
        git reset --hard HEAD
        git apply --index --whitespace=fix P.diff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Whitespace on commit
  2008-03-13  3:52 ` Junio C Hamano
@ 2008-03-13  7:34   ` Andreas Ericsson
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Ericsson @ 2008-03-13  7:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Kenneth P. Turvey, git

Junio C Hamano wrote:
> "Kenneth P. Turvey" <kt-usenet@squeakydolphin.com> writes:
> 
>> I keep getting annoying errors when I try to commit.  Git complains that I
>> have whitespace in the wrong places.  
>>
>> This is fine.. I even like it.  What I don't like is having to change this
>> stuff manually.  Is there anyway to tell git to just fix the stuff and do
>> the commit?  
>>
>> I've tried setting
>>
>> apply.whitespace = fix 
>>
>> in my .gitconfig, but that doesn't seem to help when doing commits.
> 
> Yeah, that is to protect yourself from whitespace mess _other people_
> threw at you in a patch form.
> 
> You can ask git to fix your own stuff up, by pretending that you are that
> other person who made the mess, by doing:
> 
> 	git diff HEAD >P.diff
>         git reset --hard HEAD
>         git apply --index --whitespace=fix P.diff
> 

I have exactly that (except my P.diff sits in /tmp under a different name)
as an alias named wsfix. Here's how to make one of your own, Kenneth:

git config --global alias wsfix '!git diff HEAD >P.diff && git reset --hard HEAD && git apply --index --whitespace=fix P.diff && rm -f P.diff'

Note that there are no newlines in the above command. When you get the whitespace
warnings, just run "git wsfix" and you'll be good to go.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-13  7:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-13  3:38 Whitespace on commit Kenneth P. Turvey
2008-03-13  3:52 ` Junio C Hamano
2008-03-13  7:34   ` Andreas Ericsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).