# git diff - no newline after @@ ?

7 messages from 2006-08-18 to 2006-08-18. Participants: Petr Sebor, Alex Riesen, Jakub Narebski, Jeff King.
Thread: https://gitlist.dev/t/5322

## Petr Sebor, 2006-08-18 12:10

Subject: git diff - no newline after @@ ?
Message-ID: <44E5AE42.6090506@scssoft.com>
URL: https://gitlist.dev/e/44E5AE42.6090506%40scssoft.com

```
Hello,

has anyone noticed that the 'git diff' output somehow lacks the newline 
after the @@ tag?

The linux-kernel list is full of diffs whose hunks begin like:

@@ -1475,6 +1475,7 @@ int do_coredump(long signr, int exit_cod

@@ -1516,22 +1517,34 @@ int do_coredump(long signr, int exit_cod

@@ -1428,7 +1442,7 @@ static int elf_core_dump(long signr, str

instead of:

@@ -1475,6 +1475,7 @@
 int do_coredump(long signr, int exit_cod

@@ -1516,22 +1517,34 @@
 int do_coredump(long signr, int exit_cod

@@ -1428,7 +1442,7 @@
 static int elf_core_dump(long signr, str


It is not only a problem of the linux-kernel, my local git installation 
suffers from this as well...

Regards
Petr

```

## Alex Riesen, 2006-08-18 12:25

Subject: Re: git diff - no newline after @@ ?
Message-ID: <81b0412b0608180525t284d3124j867a9461bf14ed91@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0608180525t284d3124j867a9461bf14ed91%40mail.gmail.com
In-Reply-To: <44E5AE42.6090506@scssoft.com>

```
On 8/18/06, Petr Sebor <petr@scssoft.com> wrote:
> Hello,
>
> has anyone noticed that the 'git diff' output somehow lacks the newline
> after the @@ tag?
>

Why should it? It's hunk comment.

```

## Petr Sebor, 2006-08-18 12:37

Subject: Re: git diff - no newline after @@ ?
Message-ID: <44E5B496.3070901@scssoft.com>
URL: https://gitlist.dev/e/44E5B496.3070901%40scssoft.com
In-Reply-To: <81b0412b0608180525t284d3124j867a9461bf14ed91@mail.gmail.com>

```
Alex Riesen wrote:
> On 8/18/06, Petr Sebor <petr@scssoft.com> wrote:
>> Hello,
>>
>> has anyone noticed that the 'git diff' output somehow lacks the newline
>> after the @@ tag?
>>
>
> Why should it? It's hunk comment.
Hunk comment? Maybe we don't understand each other...

check another example:

--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -13,6 +13,7 @@ #include <linux/stddef.h>
 #include <linux/types.h>
 #include <linux/compiler.h>
 #include <linux/bitops.h>
+#include <linux/memleak.h>
 #include <asm/byteorder.h>
 #include <asm/bug.h>

whereas gnu diff would output

--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -13,6 +13,7 @@
 #include <linux/stddef.h>
 #include <linux/types.h>
 #include <linux/compiler.h>
 #include <linux/bitops.h>
+#include <linux/memleak.h>
 #include <asm/byteorder.h>
 #include <asm/bug.h>

Petr

```

## Jakub Narebski, 2006-08-18 12:40

Subject: Re: git diff - no newline after @@ ?
Message-ID: <ec4cfi$9dn$1@sea.gmane.org>
URL: https://gitlist.dev/e/ec4cfi%249dn%241%40sea.gmane.org
In-Reply-To: <44E5B496.3070901@scssoft.com>

```
Petr Sebor wrote:

> Alex Riesen wrote:
>> On 8/18/06, Petr Sebor <petr@scssoft.com> wrote:
>>> Hello,
>>>
>>> has anyone noticed that the 'git diff' output somehow lacks the newline
>>> after the @@ tag?
>>>
>>
>> Why should it? It's hunk comment.
> Hunk comment? Maybe we don't understand each other...

Hunk comment as in "diff -p":

  -p     Show which C function each change is in.

(which is simpliefied to: show first line preceding hunk which begins with
word character in first column). 

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Jeff King, 2006-08-18 12:44

Subject: Re: git diff - no newline after @@ ?
Message-ID: <20060818124428.GA22328@sigio.intra.peff.net>
URL: https://gitlist.dev/e/20060818124428.GA22328%40sigio.intra.peff.net
In-Reply-To: <44E5B496.3070901@scssoft.com>

```
On Fri, Aug 18, 2006 at 02:37:42PM +0200, Petr Sebor wrote:

> >>has anyone noticed that the 'git diff' output somehow lacks the newline
> >>after the @@ tag?
> >Why should it? It's hunk comment.
> Hunk comment? Maybe we don't understand each other...

The intent of a hunk comment is to give the user some context. Note how
it's usually the C function name, even if the declaration of that
function isn't the line right before the context lines?

> check another example:
> 
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -13,6 +13,7 @@ #include <linux/stddef.h>
> #include <linux/types.h>
> #include <linux/compiler.h>
> #include <linux/bitops.h>
> +#include <linux/memleak.h>
> #include <asm/byteorder.h>
> #include <asm/bug.h>

The function detection is very simple (I believe it just looks for the
closest preceding line without any prior whitespace).

> whereas gnu diff would output

Try diff -p to get a hunk comment.

-Peff

```

## Petr Sebor, 2006-08-18 13:19

Subject: Re: git diff - no newline after @@ ?
Message-ID: <44E5BE60.5010901@scssoft.com>
URL: https://gitlist.dev/e/44E5BE60.5010901%40scssoft.com
In-Reply-To: <20060818124428.GA22328@sigio.intra.peff.net>

```
Jeff King wrote:
> Try diff -p to get a hunk comment.
>
> -Peff
>   

Ouch.... got it. Is there a way to turn the comment generation off btw?

Sorry for the noise...

Petr

```

## Jakub Narebski, 2006-08-18 13:42

Subject: Re: git diff - no newline after @@ ?
Message-ID: <ec4g4v$m4v$1@sea.gmane.org>
URL: https://gitlist.dev/e/ec4g4v%24m4v%241%40sea.gmane.org
In-Reply-To: <44E5BE60.5010901@scssoft.com>

```
Petr Sebor wrote:

> Jeff King wrote:
>> Try diff -p to get a hunk comment.
>>
>> -Peff
>>   
> 
> Ouch.... got it. Is there a way to turn the comment generation off btw?

Other than GIT_DIFF_OPTS (although how to turn off present -p option), or
GIT_EXTERNAL_DIFF (see git-diff-tree(1))?

Why do you want to turn it off? patch understands this format...
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```
