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

Re: Diff output from a rewrite of a function

From
Robin Rosenberg <robin.rosenberg.lists@dewire.com>
Date
Mar 8, 2007, 22:01 UTC
Message-ID
<200703082301.35774.robin.rosenberg.lists@dewire.com>
In-Reply-To
<Pine.LNX.4.64.0703082049060.19974@kivilampi-30.cs.helsinki.fi>
torsdag 08 mars 2007 20:04 skrev Ilpo Järvinen:
Show 16 quoted lines
> Hi,
> 
> I have a C source file in which couple of functions are fully rewritten 
> (only a part of the file), almost no real similarities (block closing 
> parents will obviously match still and couple of other keyword lines here 
> and there). I wonder if there is way to produce diff that does not get 
> confused by the empty lines / identical lines that are present in both 
> original and the modified version. Default diff output is very bad looking 
> (IMHO) because these identical lines cause a "synchronization point" to 
> occur, that is, each identical line of the original is not considered as 
> +/- but left as is. Thus I have something like 3-6 add+del blocks per 
> function with a part of the change rather than e.g., one block per 
> function or so... I found -B from man git-diff-files, but I guess 
> "complete rewrite changes" means whole files as it did do anything.
> 
> Any ideas?

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'm currently using 1.4.2, if that's significant.
> 
That was 1.5, but I think that part didn't change.
-- robin
Previous: Ilpo JärvinenNext: Junio C Hamano
Message 2 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.