git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: Re: [PATCH 5/6] log: pass rev_info to git_log_config()
Date: Thu, 04 Oct 2012 21:16:14 -0700	[thread overview]
Message-ID: <7vk3v5v9ip.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7v1uhe3efa.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Thu, 04 Oct 2012 00:05:29 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> So we would need to do something like:
>
>     - call git_log_config() first to let diff_context_default
>       updated from the configuration as before.  find the values of
>       grep.* defaults at the same time, but stash it away in a
>       separate "struct grep_opt" (yuck);
>
>     - call init_revisions() and let it initialize revs->grep_filter
>       and revs->diffopt as before;
>
>     - copy the grep.* defaults we learned during git_log_config() to
>       revs->grep_filter.
>
> which is a bit yucky, but survivable.

After thinking about it a bit more, I came to a conclusion that the
configuration handling lifted from builtin/grep.c needs a much
larger overhaul.

The grep_config() function takes one instance of grep_opt as a
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.  The codepath under discussion in this thread
   is a prime example why that arrangement is not always possible.

 - 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.

The right way to arrange your configuration callback is probably to
model it after how diff configuration variables are handled.  You
call git_config() once, and remember the values you read in set of
static variables. Later, whenever you need to instantiate a grep_opt,
you initialize it from these static variables.

All of the above did not matter back when the code in builtin/grep.c
was isolated and the configuration was never meant to be used by
other subsystems.  But the last two patches in this series do want
to break that assumption, so grep_config() needs to be rethought.

Luckily, we don't have to have this in the upcoming 1.8.0 release
(it is is too late for any topic that is not a regression fix).

  reply	other threads:[~2012-10-05  6:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-01 22:44 [ANNOUNCE] Git v1.8.0-rc0 Junio C Hamano
2012-10-03 20:18 ` grep.patternType (was: Re: [ANNOUNCE] Git v1.8.0-rc0) Junio C Hamano
2012-10-03 22:14   ` grep.patternType Junio C Hamano
2012-10-04  6:05     ` grep.patternType Michal Kiedrowicz
2012-10-05  5:38     ` grep.patternType J Smith
2012-10-04  1:33   ` [PATCH 0/6] Tying loose ends of extended "grep" Junio C Hamano
2012-10-04  1:33     ` [PATCH 1/6] grep: move configuration support to top-level grep.[ch] Junio C Hamano
2012-10-04  1:33     ` [PATCH 2/6] grep: move pattern-type bits " Junio C Hamano
2012-10-04  1:33     ` [PATCH 3/6] log --grep: use the same helper to set -E/-F options as "git grep" Junio C Hamano
2012-10-04  8:09       ` Jeff King
2012-10-04  1:33     ` [PATCH 4/6] log --grep: accept --basic-regexp and --perl-regexp Junio C Hamano
2012-10-04  8:12       ` Jeff King
2012-10-04 16:44         ` Junio C Hamano
2012-10-04  1:33     ` [PATCH 5/6] log: pass rev_info to git_log_config() Junio C Hamano
2012-10-04  7:05       ` Junio C Hamano
2012-10-05  4:16         ` Junio C Hamano [this message]
2012-10-05 15:33           ` Jeff King
2012-10-05 19:07             ` Junio C Hamano
2012-10-04  1:33     ` [PATCH 6/6] log --grep: honor grep.patterntype etc. configuration variables Junio C Hamano
2012-10-04  8:17       ` Jeff King
2012-10-04 16:46         ` Junio C Hamano
2012-10-04 18:01           ` Jeff King
2012-10-04 19:09             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vk3v5v9ip.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).