diff options
author | Jeff King <peff@peff.net> | 2012-02-02 03:19:28 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-02-02 10:36:07 -0800 |
commit | e1327023ea22c3bf57e7d28596da356043f073fc (patch) | |
tree | a46524ec0523c19eae73fad72599d0583fd6df9c /.gitignore | |
parent | grep: move sha1-reading mutex into low-level code (diff) | |
download | tgif-e1327023ea22c3bf57e7d28596da356043f073fc.tar.xz |
grep: refactor the concept of "grep source" into an object
The main interface to the low-level grep code is
grep_buffer, which takes a pointer to a buffer and a size.
This is convenient and flexible (we use it to grep commit
bodies, files on disk, and blobs by sha1), but it makes it
hard to pass extra information about what we are grepping
(either for correctness, like overriding binary
auto-detection, or for optimizations, like lazily loading
blob contents).
Instead, let's encapsulate the idea of a "grep source",
including the buffer, its size, and where the data is coming
from. This is similar to the diff_filespec structure used by
the diff code (unsurprising, since future patches will
implement some of the same optimizations found there).
The diffstat is slightly scarier than the actual patch
content. Most of the modified lines are simply replacing
access to raw variables with their counterparts that are now
in a "struct grep_source". Most of the added lines were
taken from builtin/grep.c, which partially abstracted the
idea of grep sources (for file vs sha1 sources).
Instead of dropping the now-redundant code, this patch
leaves builtin/grep.c using the traditional grep_buffer
interface (which now wraps the grep_source interface). That
makes it easy to test that there is no change of behavior
(yet).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions