builtin/grep.c: make configuration callback more reusable
commit15fabd1bbd4c997d0edb2249295e2717bc18b6c7
authorJunio C Hamano <gitster@pobox.com>
Tue, 9 Oct 2012 23:04:12 +0000 (9 16:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Oct 2012 23:04:12 +0000 (9 16:04 -0700)
treed39e49dc8581712c6013d20707631252627e5c46
parentf84667def209e4a84e37e8488a08e9eca3f208c1
builtin/grep.c: make configuration callback more reusable

The grep_config() function takes one instance of grep_opt as its
callback parameter, and populates it by running git_config().

This has three practical implications:

 - You have to have an instance of grep_opt already when you call
   the configuration, but that is not necessarily always true.  You
   may be trying to initialize the grep_filter member of rev_info,
   but are not ready to call init_revisions() on it yet.

 - It is not easy to enhance grep_config() in such a way to make it
   cascade to other callback functions to grab other variables in
   one call of git_config(); grep_config() can be cascaded into from
   other callbacks, but it has to be at the leaf level of a cascade.

 - If you ever need to use more than one instance of grep_opt, you
   will have to open and read the configuration file(s) every time
   you initialize them.

Rearrange the configuration mechanism and model it after how diff
configuration variables are handled.  An early call to git_config()
reads and remembers the values taken from the configuration in the
default "template", and a separate call to grep_init() uses this
template to instantiate a grep_opt.

The next step will be to move some of this out of this file so that
the other user of the grep machinery (i.e. "log") can use it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c