From: Davide Libenzi Date: Sun, 25 Sep 2005 16:08:20 GMT Subject: Re: Implementing diff, was Re: git 0.99.7b doesn't build on Cygwin Message-ID: In-Reply-To: On Sun, 25 Sep 2005, Johannes Schindelin wrote: >> Linus Torvalds writes: >> >>> The GNU diff sources are hard enough to read that I don't think we want to >>> try to merge the unified diff generation from there. >> >> I was talking with GNU diff maintainer and his impression was >> that CVS folks may have done enough libification -- I'll find >> time to look at CVS code and see how much damage we are talking >> about. > > I am not sure if it would be wise to completely do away with the current > method: Often, I call git-diff with my own wdiff-helper. Also, options > like "-b" to diff are very useful, and would have to be implemented, too. What you'd have to do, if you chose to use diffutils stuff, is to transform the main() of diff in diff_main(), use setjmp/longjmp to capture its exit()s, and make it use a proper allocator (if you want to avoid leaks upon aborts). You can see an example inside the diff/libgdiff directory of this packages: https://www.cvshome.org http://www.opencm.org In that way, instead of executing "diff -u ...", you'd call diff_main() with the proper args array. The CVS one (the other project seems dead, and they lifted the thing from CVS anyway) should be readily usable. - Davide