threads / discuss / 16762

white spaces in a patch

Subject: white spaces in a patch

## tl;dr

12 messages between Dec 17, 2008 and Dec 17, 2008.

replies: 11people: 7as markdown or json

Mark Ryden· Dec 17, 2008, 07:31 UTC · lore
Hello,

It occurred to me that I prepared some patch for a git tree, and then when testing git-apply on it (on the original tree) I saw some "white spaces" errors. I know that I can run: "git --whitespace=fix apply" on my patch and than create the patch again ; in this way it will be created without white spaces.

Suppose I create a patch file (let's say : patch.txt)
1) Is there a way to check whether there are white spaces in this
file without running git-apply?
2) Is there a way to get some messages about that there are white spaces
when creating a git patch?

Regards, Mark

Junio C Hamano· Dec 17, 2008, 07:34 UTC · re: Mark Ryden · lore

Re: white spaces in a patch

"Mark Ryden" <markryde@gmail.com> writes:
> 1) Is there a way to check whether there are white spaces in this
> file without running git-apply?
"sed -n -e '/^+.*[ 	]$/p' patch.txt" perhaps?
> 2) Is there a way to get some messages about that there are white spaces
> when creating a git patch?

Doesn't "git diff" highlight whitespace errors? That way, you can catch errors before you make a commit that has them.

Mark Ryden· Dec 17, 2008, 11:44 UTC · re: Junio C Hamano · lore

Re: white spaces in a patch

Hello,
I tried:
git apply patch1.txt
patch1.txt:34: trailing whitespace.
				
patch1.txt:53: trailing whitespace.

And "git diff" show differences but **does not** highlight anything. I tried in tchs and in Bash.

Any ideas ? does "git diff" does  highlight for anyone ?

Rgs, Mark

On Wed, Dec 17, 2008 at 9:34 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> "Mark Ryden" <markryde@gmail.com> writes:
>
>> 1) Is there a way to check whether there are white spaces in this
>> file without running git-apply?
>
> "sed -n -e '/^+.*[      ]$/p' patch.txt" perhaps?
>
>> 2) Is there a way to get some messages about that there are white spaces
>> when creating a git patch?
>
> Doesn't "git diff" highlight whitespace errors?  That way, you can catch
> errors  before you make a commit that has them.
>
Sverre Rabbelier· Dec 17, 2008, 12:13 UTC · re: Mark Ryden · lore

Re: white spaces in a patch

On Wed, Dec 17, 2008 at 12:44, Mark Ryden <markryde@gmail.com> wrote:
> Any ideas ? does "git diff" does  highlight for anyone ?
Do you have color on?
-- 
Cheers,

Sverre Rabbelier
Mark Ryden· Dec 17, 2008, 12:13 UTC · re: Sverre Rabbelier · lore

Re: white spaces in a patch

What do you mean ? where ? how ? Mark

On Wed, Dec 17, 2008 at 2:13 PM, Sverre Rabbelier <srabbelier@gmail.com> wrote:
Show 10 quoted lines
> On Wed, Dec 17, 2008 at 12:44, Mark Ryden <markryde@gmail.com> wrote:
>> Any ideas ? does "git diff" does  highlight for anyone ?
>
> Do you have color on?
>
> --
> Cheers,
>
> Sverre Rabbelier
>
Thomas Jarosch· Dec 17, 2008, 12:15 UTC · re: Mark Ryden · lore

Re: white spaces in a patch

On Wednesday, 17. December 2008 13:13:34 Mark Ryden wrote: [colors in diff]

> What do you mean ?
> where ? how ?
This should do the trick:

git config --global color.diff auto git config --global color.status auto git config --global color.branch auto

Thomas
Mark Ryden· Dec 17, 2008, 12:22 UTC · re: Thomas Jarosch · lore

Re: white spaces in a patch

Thnks! In fact, the first line was enough! git config --global color.diff auto Mark

On Wed, Dec 17, 2008 at 2:15 PM, Thomas Jarosch <thomas.jarosch@intra2net.com> wrote:

Show 14 quoted lines
> On Wednesday, 17. December 2008 13:13:34 Mark Ryden wrote:
> [colors in diff]
>> What do you mean ?
>> where ? how ?
>
> This should do the trick:
>
> git config --global color.diff auto
> git config --global color.status auto
> git config --global color.branch auto
>
> Thomas
>
>
Matthieu Moy· Dec 17, 2008, 20:02 UTC · re: Mark Ryden · lore

Re: white spaces in a patch

"Mark Ryden" <markryde@gmail.com> writes:
> Thnks!
> In fact, the first line was enough!
> git config --global color.diff auto

Yes, but you may appreciate color in other commands (log, status, ...). Then, "color.ui = auto" is your friend.

-- 
Matthieu
Jeff King· Dec 17, 2008, 12:22 UTC · re: Thomas Jarosch · lore

Re: white spaces in a patch

On Wed, Dec 17, 2008 at 01:15:56PM +0100, Thomas Jarosch wrote:
Show 5 quoted lines
> This should do the trick:
> 
> git config --global color.diff auto
> git config --global color.status auto
> git config --global color.branch auto
These days we have
  git config --global color.ui auto
-Peff
Sverre Rabbelier· Dec 17, 2008, 12:16 UTC · re: Mark Ryden · lore

Re: white spaces in a patch

On Wed, Dec 17, 2008 at 13:13, Mark Ryden <markryde@gmail.com> wrote:
> On Wed, Dec 17, 2008 at 2:13 PM, Sverre Rabbelier <srabbelier@gmail.com> wrote:
>> Do you have color on?
$ git config color.diff true
-- 
Cheers,

Sverre Rabbelier
Johannes Schindelin· Dec 17, 2008, 12:08 UTC · re: Junio C Hamano · lore

Re: white spaces in a patch

Hi,
On Tue, 16 Dec 2008, Junio C Hamano wrote:
Show 7 quoted lines
> "Mark Ryden" <markryde@gmail.com> writes:
> 
> > 2) Is there a way to get some messages about that there are white 
> >    spaces when creating a git patch?
> 
> Doesn't "git diff" highlight whitespace errors?  That way, you can catch 
> errors before you make a commit that has them.
Not to mention "git diff --check", which should catch them, too.

Ciao, Dscho

Mark Ryden· Dec 17, 2008, 12:10 UTC · re: Johannes Schindelin · lore

Re: white spaces in a patch

Hello, Thanks!

"git diff --check" indeed tells about trailing whitespace Mark

On Wed, Dec 17, 2008 at 2:08 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 18 quoted lines
> Hi,
>
> On Tue, 16 Dec 2008, Junio C Hamano wrote:
>
>> "Mark Ryden" <markryde@gmail.com> writes:
>>
>> > 2) Is there a way to get some messages about that there are white
>> >    spaces when creating a git patch?
>>
>> Doesn't "git diff" highlight whitespace errors?  That way, you can catch
>> errors before you make a commit that has them.
>
> Not to mention "git diff --check", which should catch them, too.
>
> Ciao,
> Dscho
>
>

← back to recent threads