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

Re: git diff --check always shows line 1 for blank at EOF for new files

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 7, 2010, 09:32 UTC
Message-ID
<20101007093258.GA10941@burratino>
In-Reply-To
<4CAC411E.3010204@gmx.de>
Hi Christoph,
Christoph Mallon wrote:
Show 17 quoted lines
>   git init test
>   cd test
>   printf 'a\nb\nc\n\n' > file
>   git add -AN
>   git diff --check
> 
> The last command will show "file:1: new blank line at EOF.".
> 
> It works fine, if the diff is not against /dev/null, e.g.:
>   git init test
>   cd test
>   printf 'a\nb\nc\n' > file
>   git add -A
>   echo >> file
>   git diff --check
> 
> This correctly shows "file:4: new blank line at EOF.".
Try this:
    git init test
    cd test
    printf 'a\nb\nc\n' > file
    git add -A
    echo hello >> file
    echo >> file
    git diff --check

As you can see, it still returns line 4, which is the beginning of the hunk that adds the blank line.

A change to make it print the line number of the blank line itself does not sound so bad, though.

Previous: Christoph MallonNext: Christoph Mallon
Message 2 of 4 in “git diff --check always shows line 1 for blank at EOF for new files”
  1. Christoph MallonOct 6, 2010
  2. Jonathan NiederOct 7, 2010
  3. Christoph MallonOct 7, 2010
  4. Junio C HamanoOct 10, 2010

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.