git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git diff - no newline after @@ ?

From
Jeff King <peff@peff.net>
Date
Aug 18, 2006, 12:44 UTC
Message-ID
<20060818124428.GA22328@sigio.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?

Show 11 quoted 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
Previous: Jakub NarebskiNext: Petr Sebor
Message 5 of 7 in “git diff - no newline after @@ ?”
  1. Petr SeborAug 18, 2006
  2. Alex RiesenAug 18, 2006
  3. Petr SeborAug 18, 2006
  4. Jakub NarebskiAug 18, 2006
  5. Jeff KingAug 18, 2006
  6. Petr SeborAug 18, 2006
  7. Jakub NarebskiAug 18, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.