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

Re: Split up tree diff functions into tree-diff.c library

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 21, 2005, 15:19 UTC
Message-ID
<Pine.LNX.4.64.0510210814310.10477@g5.osdl.org>
In-Reply-To
<7v64rr2y4q.fsf@assigned-by-dhcp.cox.net>
On Thu, 20 Oct 2005, Junio C Hamano wrote:
Show 6 quoted lines
>
> I have not closely studied the user of this change, rev-list,
> but I have a hunch that you might be better off, if you define a
> new diff "format", DIFF_FORMAT_CALLBACK, and hook into
> diff_flush(), instead of hooking into diff_addremove() and
> diff_change().
No, I did that on purpose.

I did _not_ want the library interface users to have to use the flushing and all the associated memory management and complexity issues.

The thing is, the only thing rev-list wants to know is whether there was a diff at all, and I want to eventually make "opt->change()" and "opt->add_remove()" return a possible error code so that the whole diff library can just stop on the first change, since once we've seen _any_ change, we don't care any more.

Also, by taking it over at this lieve, you don't need to do any of the diff setup at all to use the core routines.

Now, if somebody _wants_ to hook into flushing, you can still do so: you just do

	opt->add_remove = diff_addremove;
	opt->change = diff_change;

and then you can hook into the higher-level functions if you want to. But for a lot of uses, I bet we do _not_ want to. And those higher-level routines have had some _serious_ memory use problems etc: by hooking into the lower level, we can bypass all of that.

(A memory leak in diff in git-rev-parse would be deadly on big archives).
> Right now, you are only making the parallel tree traversing and
> comparing part from diff-tree available in the library form
> (which is fine), but that way leaves the door open for it to
> also use the rest of the diffcore machinery.

The point is, we don't _want_ to use the rest of the diffcore machinery. It's too expensive and fragile.

		Linus
Previous: Junio C Hamano
Message 3 of 3 in “Split up tree diff functions into tree-diff.c library”
  1. Linus TorvaldsOct 21, 2005
  2. Junio C HamanoOct 21, 2005
  3. Linus TorvaldsOct 21, 2005

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.