From: Linus Torvalds Date: Fri, 21 Oct 2005 15:19:30 GMT Subject: Re: Split up tree diff functions into tree-diff.c library Message-ID: In-Reply-To: <7v64rr2y4q.fsf@assigned-by-dhcp.cox.net> On Thu, 20 Oct 2005, Junio C Hamano wrote: > > 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