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

Re: range-diff should suppress context-only changes?

From
Johannes Altmanninger <aclopte@gmail.com>
Date
Nov 17, 2020, 21:35 UTC
Message-ID
<20201117213551.2539438-1-aclopte@gmail.com>
In-Reply-To
<xmqqmtzvikwi.fsf@gitster.c.googlers.com>
Show 7 quoted lines
> > I wonder if it would be reasonable to suppress range-diff hunks in which
> > all of the changed lines are context lines.
> 
> Sounds like a reasonable thing to do.  As we know the shape of what
> is compared in the outer diff we should be able to accurately notice
> where hunk boundaries are and a hunk whose change is only on context
> lines.

Here are patches to ignore context-only changes in range-diff's output. I'm not completely happy with the changes, they feel a bit too hacky. Maybe someone has better ideas.

This still gives output like this one, that could be improved in future
	1:  7a3dac8 ! 1:  119bc78 Change
	    @@ some-other-file
	      7
	      8
	      9
	    - Old context line
	    + New context line
	    -## file ##
	    +## file => renamed-file ##
	     @@
	      1
	     -2
I think it should be
	1:  7a3dac8 ! 1:  119bc78 Change
	    -## file ##
	    +## file => renamed-file ##
	     @@
	      1
	     -2
I'm not sure if this is a feasible improvement.

"## <filename> ##" normally is a diff section header (hence the "@@ some-other-file" hunk above) but here the section header itself is changed..

Previous: Junio C HamanoNext: Johannes Altmanninger
Message 3 of 7 in “range-diff should suppress context-only changes?”
  1. Jeff KingNov 5, 2020
  2. Junio C HamanoNov 5, 2020
  3. Johannes AltmanningerNov 17, 2020
  4. 1/3 range-diff: move " ## filename ##" headers to the first columnJohannes Altmanninger, Nov 17, 2020
  5. 2/3 range-diff: ignore context-only changesJohannes Altmanninger, Nov 17, 2020
  6. Eric SunshineNov 17, 2020
  7. 3/3 range-diff: only compute patch diff when patches are differentJohannes Altmanninger, Nov 17, 2020

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.