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

Re: Diff output from a rewrite of a function

From
Junio C Hamano <junkio@cox.net>
Date
Mar 8, 2007, 23:24 UTC
Message-ID
<7vbqj38gkp.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200703082301.35774.robin.rosenberg.lists@dewire.com>
Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:
Show 5 quoted lines
> Increase the context size from the default three lines.  Something like
> diff -U 7 old new will require larger chunks of unchanged code for diff
> break up a hunk. With git you can do 
>
> GIT_DIFF_OPTS=-u7 git-diff-....

I think you can say "git diff -U7" to do what you are describing, but I do not think that does what you want. I think what you want is a "negative context", which says "do not consider group of lines less than N lines as matching between preimage and postimage". What Ilpo wants is to see something like this:

-	Deleted 1
-	Deleted 2
-	Deleted 3
...
-	Deleted 400
+	Added 1
+	Added 2
+	Added 3
...
+	Added 500
	/* happens to match because this was left intact,too */
-	Deleted 401
-	Deleted 402
-	Deleted 403
+	Added 501

as if the small context lines that happen to match are also part of the change, like this:

- Deleted 1 - Deleted 2 - Deleted 3 ... - Deleted 400 - /* happens to match because this was left intact,too */ - Deleted 401 - Deleted 402 - Deleted 403 + Added 1 + Added 2 + Added 3 ... + Added 500 + /* happens to match because this was left intact,too */ + Added 501

Previous: Robin RosenbergNext: Ilpo Järvinen
Message 3 of 5 in “Diff output from a rewrite of a function”
  1. Ilpo JärvinenMar 8, 2007
  2. Robin RosenbergMar 8, 2007
  3. Junio C HamanoMar 8, 2007
  4. Ilpo JärvinenMar 9, 2007
  5. Robin RosenbergMar 9, 2007

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.