From: Junio C Hamano Date: Fri, 24 Oct 2008 21:12:17 GMT Subject: Re: [PATCH 3/5] refactor userdiff textconv code Message-ID: <7v3ail3dfy.fsf@gitster.siamese.dyndns.org> In-Reply-To: <20081024025330.GC2831@coredump.intra.peff.net> Jeff King writes: > I think this is much cleaner. I have a nagging worry that a > text-converted filespec might live longer than I expect. Maybe it would > make sense to free the filespec data after the diff has been generated > (and then further populate_filespec calls would just restore the > original data). Either that or drop data_is_textconv and have two sets of pair in filespec, one for real data and another purely for diff text generation. But I have a very naïve question. Why isn't this just primarily a patch to diff.c::builtin_diff() function? That is, you let fill_mmfile() to fill the real data in mf1 and mf2 as before, ask one/two if they have textconv, and if so, convert mf1 and mf2 in place, and let xdl work on it, like... if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0) die("unable to read files to diff"); + if (has_textconv(one)) + apply_textconv(one, &mf1); + if (has_textconv(two)) + apply_textconv(two, &mf2); if (!DIFF_OPT_TST(o, TEXT) && - (diff_filespec_is_binary(one) || diff_filespec_is_binary(two))) { + ( (diff_filespec_is_binary(one) && !has_textconv(one)) || + (diff_filespec_is_binary(two) && !has_textconv(two)) )) { /* Quite common confusing case */ ... } else { /* Crazy xdl interfaces.. */ const char *diffopts = getenv("GIT_DIFF_OPTS"); ...