# Trailing whitespace on git diff output.

2 messages from 2014-09-01 to 2014-09-01. Participants: Adria Farres, Matthieu Moy.
Thread: https://gitlist.dev/t/37471

## Adria Farres, 2014-09-01 17:47

Subject: Trailing whitespace on git diff output.
Message-ID: <20140901174709.GA23397@vimeitor>
URL: https://gitlist.dev/e/20140901174709.GA23397%40vimeitor

```
Hello,

Today, while redirecting git diff's output to a text file, I noticed git diff
leaves a trailing whitespace between different deltas of the same file (the line
that separates two different deltas). For example, committing a file with the
following content:
---
test

test
---

then changing it to the following:
---
test
test

test
test
---

committing and diffing it, leaves a trailing whitespace on line 8 of the
diff output.

Is that expected behavior? I'm using git 2.1.0.

Sorry for taking your time,

Adria

```

## Matthieu Moy, 2014-09-01 18:10

Subject: Re: Trailing whitespace on git diff output.
Message-ID: <vpq1trv9pq6.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpq1trv9pq6.fsf%40anie.imag.fr
In-Reply-To: <20140901174709.GA23397@vimeitor>

```
Adria Farres <14farresa@gmail.com> writes:

> Hello,
>
> Today, while redirecting git diff's output to a text file, I noticed git diff
> leaves a trailing whitespace between different deltas of the same file (the line
> that separates two different deltas). For example, committing a file with the
> following content:
> ---
> test
>
> test
> ---
>
> then changing it to the following:
> ---
> test
> test
>
> test
> test
> ---
>
> committing and diffing it, leaves a trailing whitespace on line 8 of the
> diff output.

That is (I replaced spaces with _):

--- a/test.txt
+++ b/test.txt
@@ -1,3 +1,5 @@
_test
+test
_
_test
+test

GNU diff does the same, and that is what I would expect: the first
column is left for + and -, and spaces are used as a prefix for the
context.

If you diff

test
x
test

and

test
test
x
test
test

you'd expect a space before the 'x' in the diff output. In your example,
there's a space before the empty string, which has the same role as the
'x' above.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```
