# Highlighting whitespace on removal with git diff

3 messages from 2010-10-20 to 2010-10-20. Participants: Stonky Fandango, Kevin Ballard, Junio C Hamano.
Thread: https://gitlist.dev/t/25482

## Stonky Fandango, 2010-10-20 00:46

Subject: Highlighting whitespace on removal with git diff
Message-ID: <AANLkTik7a8OQz2+SVTm+HjZkCtbjm6O9d12biCJ8MyZz@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTik7a8OQz2%2BSVTm%2BHjZkCtbjm6O9d12biCJ8MyZz%40mail.gmail.com

```
When I do say 'git diff', and I have added a line with a trailing
whitespace, i get a red square box highlighting the added whitespace.
(on the '+' diff line)
What I want, is the reverse - so when I delete an existing whitespace,
I get something similar, for example a blue box highlighting the
deleted whitespace (on the '-' diff line)

Currently the only notificate I get is identical
'-' and '+' diff lines, but no indication of the whitespace deleted

I know I can do this with graphical tools, but ideally would like some way
using the standard console git diff - if this is possible.

I have  the following in my .gitconfig
---
[color "diff"]
whitespace = red reverse
[core]
 whitespace=-indent-with-non-tab,trailing-space,cr-at-eol,tab-in-indent
---

Thanks,

```

## Kevin Ballard, 2010-10-20 03:15

Subject: Re: Highlighting whitespace on removal with git diff
Message-ID: <D058D986-2A83-4979-A461-F7CB34EF9448@sb.org>
URL: https://gitlist.dev/e/D058D986-2A83-4979-A461-F7CB34EF9448%40sb.org
In-Reply-To: <AANLkTik7a8OQz2+SVTm+HjZkCtbjm6O9d12biCJ8MyZz@mail.gmail.com>

```
The highlight isn't telling you what changed on the line. It's telling you that this added line has trailing whitespace, and your core.whitespace config value is set such that this is considered an error.

-Kevin Ballard

On Oct 19, 2010, at 5:46 PM, Stonky Fandango wrote:

> When I do say 'git diff', and I have added a line with a trailing
> whitespace, i get a red square box highlighting the added whitespace.
> (on the '+' diff line)
> What I want, is the reverse - so when I delete an existing whitespace,
> I get something similar, for example a blue box highlighting the
> deleted whitespace (on the '-' diff line)
> 
> Currently the only notificate I get is identical
> '-' and '+' diff lines, but no indication of the whitespace deleted
> 
> I know I can do this with graphical tools, but ideally would like some way
> using the standard console git diff - if this is possible.
> 
> I have  the following in my .gitconfig
> ---
> [color "diff"]
> whitespace = red reverse
> [core]
>  whitespace=-indent-with-non-tab,trailing-space,cr-at-eol,tab-in-indent
> ---
> 
> Thanks,
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

```

## Junio C Hamano, 2010-10-20 06:10

Subject: Re: Highlighting whitespace on removal with git diff
Message-ID: <7v4ochxuld.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v4ochxuld.fsf%40alter.siamese.dyndns.org
In-Reply-To: <D058D986-2A83-4979-A461-F7CB34EF9448@sb.org>

```
Kevin Ballard <kevin@sb.org> writes:

> The highlight isn't telling you what changed on the line. It's telling
> you that this added line has trailing whitespace, and your
> core.whitespace config value is set such that this is considered an
> error.
>
> -Kevin Ballard

Which means that, in order to check for a whitespace error you removed in
your change, you can give "-R" (reverse) option to your "git diff".

```
