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

Re: misleading diff-hunk header

From
TCTim Chase <git@tim.thechases.com>
Date
Aug 25, 2012, 00:41 UTC
Message-ID
<50381F52.9030007@tim.thechases.com>
In-Reply-To
<20120824164415.GA23262@sigill.intra.peff.net>
On 08/24/12 11:44, Jeff King wrote:
Show 35 quoted lines
> With the old code, you'd get:
> 
> 	diff --git a/old b/new
> 	index f384549..1066a25 100644
> 	--- a/old
> 	+++ b/new
> 	@@ -2,3 +2,3 @@ one
> 	 two
> 	-three
> 	+three -- modified
> 	 four
> 
> So the hunk header is showing you something useful; the element just
> above your context. But with my patch, you'd see:
> 
> 	diff --git a/old b/new
> 	index f384549..1066a25 100644
> 	--- a/old
> 	+++ b/new
> 	@@ -2,3 +2,3 @@ two
> 	 two
> 	-three
> 	+three -- modified
> 	 four
> 
> I.e., it shows the element just before the change, which is already in
> the context anyway. So it's actually less useful. Although note that the
> current behavior is not all that useful, either; it is not really giving
> you any information about the change, but rather just showing one extra
> line of context.
> 
> So I would say that which you would prefer might depend on exactly what
> you are diffing. But I would also argue that in any case where the new
> code produces a worse result, the hunk header was not all that useful to
> begin with.

If the documented purpose of "diff -p" (and by proxy diff.{type}.xfuncname) is to show the name of the *function* containing the changed lines, and all you have is a list of lines with no function names, it's pretty arbitrary to call either behavior "worse". :-)

-tkc
Previous: Jeff KingNext: Junio C Hamano
Message 10 of 14 in “misleading diff-hunk header”
  1. Tim ChaseAug 21, 2012
  2. Thomas RastAug 21, 2012
  3. Tim ChaseAug 21, 2012
  4. Johannes SixtAug 21, 2012
  5. Junio C HamanoAug 21, 2012
  6. Junio C HamanoAug 21, 2012
  7. Jeff KingAug 24, 2012
  8. Tim ChaseAug 24, 2012
  9. Jeff KingAug 24, 2012
  10. Tim ChaseAug 25, 2012
  11. Junio C HamanoAug 25, 2012
  12. Tim ChaseAug 25, 2012
  13. Stefano LattariniAug 26, 2012
  14. Junio C HamanoAug 26, 2012

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.