Re: [PATCH 1/2] grep: let grep_buffer callers specify a binary flag
- From
Jeff King <peff@peff.net>
- Date
- Feb 2, 2012, 00:52 UTC
- Message-ID
- <20120202005209.GA6883@sigill.intra.peff.net>
- In-Reply-To
- <7vhaza12ol.fsf@alter.siamese.dyndns.org>
On Wed, Feb 01, 2012 at 04:47:38PM -0800, Junio C Hamano wrote:
Show 11 quoted lines
> Jeff King <peff@peff.net> writes: > > > The caller of grep_buffer may have extra information about > > whether a buffer is binary or not (e.g., from configuration). > > Let's give them a chance to pass along that information and > > override our binary auto-detection. > > Hrm, I would have expected a patch that turns "const char *name" into a > structure that has name and drv as its members, so that later we can tell > the function more about the nature of the contents. Or a separate pointer > to drv in place of your "binary" flag word.
Hmm. Yeah, I would be OK with that, as it's really encapsulating the idea of "stuff we want to tell grep about this buffer".
What I really didn't want to do was pass the userdiff driver directly, as that feels way too much like an implementation detail (and while it can be used to avoid further lookups, it doesn't seem to make a difference in practice -- see the following patch). And passing it around became a big messy chore.
But if it were a "struct grep_context" that encapsulated those things, I think it would be much nicer (it could even carry a pointer to "struct grep_opt" in it, making the code _more_ pleasant to read, not less).
I'll take a look at re-working it that way.
-Peff