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

Treating similar blank lines between hunks as part of the hunks

From
TTTimur Tabi <timur@freescale.com>
Date
Aug 26, 2010, 20:19 UTC
Message-ID
<AANLkTikZFYSSNMENC5SmKSVt49a+WxXdO0mP=V7Mbi-Q@mail.gmail.com>

Is there any way to convince git-diff to treat blank lines between two hunks as part of the hunks for diffing? That is, if I have these two files:

----- A B C

D E -----

and

----- A F G

H E -----

git-diff will do this:
 A
-B
-C
+F
+G
-D
+H
 E
Instead, I would prefer it did this:
 A
-B
-C
-
-D
+F
+G
+
+H
E

This second diff is easier to read, especially when the number of hunks is large, but the size of each hunk is small. This can happen in source code when one function is replaced with a completely different function. Git sees the blanks in each function as being common, but everything else is completely different, so the diff is unreabable.

-- 
Timur Tabi
Linux kernel developer at Freescale
Next: Jonathan Nieder
Message 1 of 2 in “Treating similar blank lines between hunks as part of the hunks”
  1. Timur TabiAug 26, 2010
  2. Jonathan NiederAug 27, 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.