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

diff --check is stupid about blank lines

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Aug 20, 2008, 14:05 UTC
Message-ID
<20080820140517.GA1304@atjola.homenet>
Hi,

diff --check triggers not only for blank lines at the end of the file, but also at the end of the changes. That seems broken to me, unless you really dislike empty lines.

For example: git (master) $ git diff

diff --git a/git.c b/git.c
index 37b1d76..3fa1aeb 100644
--- a/git.c
+++ b/git.c
@@ -9,6 +9,8 @@ const char git_usage_string[] =
 const char git_more_info_string[] =
        "See 'git help COMMAND' for more information on a specific command.";
 
+int new_var = 0;
+
 static int use_pager = -1;
 struct pager_config {
        const char *cmd;

git (master) $ git diff --check
git.c:13: ends with blank lines.

But that blank line was of course intentional.

I'm not quite sure why that happens though. The code in
checkdiff_consume seems to reset the flag when it sees context lines,
but apparently that does not work for some reason.

git version 1.6.0.36.g3814c

Björn
Next: Jeff King
Message 1 of 7 in “diff --check is stupid about blank lines”
  1. Björn SteinbrinkAug 20, 2008
  2. Jeff KingAug 20, 2008
  3. Junio C HamanoAug 20, 2008
  4. Junio C HamanoAug 20, 2008
  5. Björn SteinbrinkAug 20, 2008
  6. Jeff KingAug 20, 2008
  7. Junio C HamanoAug 20, 2008

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.