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

Re: git diff woes

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 12, 2007, 10:01 UTC
Message-ID
<Pine.LNX.4.64.0711120958500.4362@racer.site>
In-Reply-To
<4738208D.1080003@op5.se>
Hi,
On Mon, 12 Nov 2007, Andreas Ericsson wrote:
Show 14 quoted lines
> I recently ran into an oddity with the excellent git diff output
> format. When a function declaration changes in the same patch as
> something else in a function, the old declaration is used with the
> diff hunk-headers.
> 
> [...]
> 
> It definitely looks like a bug, but really isn't, since an earlier hunk
> (pasted below) changes the declaration.
>
> [...]
>
> This makes it impossible to trust the hunk-header info if the declaration
> changes.

Huh? You admit yourself that it is not a bug. And sure you can trust the hunk header. Like most of the things, the relate to the _original_ version, since the diff is meant to be applied as a forward patch.

So for all practical matters, the diff shows the correct thing: "in this hunk, which (still) belongs to that function, change this and this."

Of course, that is only the case if you accept that the diff should be applied _in total_, not piecewise. IOW if you are a fan of GNU patch which happily clobbers your file until it fails with the last hunk, you will not be happy.

Ciao, Dscho

Previous: Andreas EricssonNext: Andreas Ericsson
Message 2 of 13 in “git diff woes”
  1. Andreas EricssonNov 12, 2007
  2. Johannes SchindelinNov 12, 2007
  3. Andreas EricssonNov 12, 2007
  4. Johannes SchindelinNov 12, 2007
  5. Andreas EricssonNov 12, 2007
  6. Junio C HamanoNov 12, 2007
  7. Andreas EricssonNov 13, 2007
  8. Johannes SchindelinNov 13, 2007
  9. Miles BaderNov 13, 2007
  10. Andreas EricssonNov 13, 2007
  11. diffcore: Allow users to decide what funcname to useAndreas Ericsson, Nov 13, 2007
  12. Jakub NarebskiNov 13, 2007
  13. Andreas EricssonNov 13, 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.