All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: Tanay Abhra <tanayabh@gmail.com>,
	git@vger.kernel.org, Ramkumar Ramachandra <artagnon@gmail.com>
Subject: Re: [PATCH v7 1/2] add `config_set` API for caching config-like files
Date: Thu, 10 Jul 2014 09:46:14 -0700	[thread overview]
Message-ID: <xmqqvbr588mh.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <vpqa98hwnxp.fsf@anie.imag.fr> (Matthieu Moy's message of "Thu, 10 Jul 2014 11:41:38 +0200")

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> After thinking about it a bit more, I think <file, line> support
>> needs to be done not as a mere client of the generic, uncached
>> git_config() API that we have had for forever, like the current
>> iteration, but needs to know a bit more about the state the caller
>> of the callback (namely, git_parse_source()), and we obviously do
>> not want to expose that machinery to anybody other than the
>> implementation of the config subsystem (to which the new facility
>> this GSoC project adds belongs to), so in that sense you have to
>> have your code in the same config.c file anyway.
>
> I do not buy the argument. Why would callers of the callback-style API
> not be allowed to give <file, line> errors?
>
> To me, it is a weakness of the API that <file, line> information is not
> available to callback functions, regardless of the config-cache.

I agree that it is good to allow scan-all-config-items-with-callback
callers to learn <file, line>, but that is irrelevant.  Perhaps you
misread what I envision as the endgame of this thing to be and that
is where our differences come from.  One thing I think would be good
to see in the endgame will be to give the benefit of the caching
layer to the callback callers without having them change a single
line of their code.

One possible sequence of changes to make it happen would go like
this, roughly in this order:

 - rename the current git_config() to git_config_raw(), and
   make it static to the config.c.

 - write a thin wrapper git_config() around git_config_raw() in
   config.c, until caching layer learns the iterator.

 - write caching layer to read from git_config_raw().

 - teach git_config_raw() feed its callback functions to learn the
   <file, line> information.  git_configset_get_<type> can then
   start using this in their error reporting.

 - implement iterator in the caching layer.

 - rewrite git_config() that was a thin wrapper around
   git_config_raw() by using the iterator over the cached values.

 - (optional) think about ways to give <file, line> information to
   the callback style callers.  Perhaps we need git_config_2().
   Perhaps we can rewrite all callers of git_config().  We do not
   have to decide it now.

Between git_parse_source() and git_config_raw() we would need to
pass the line-number information, but there is no reason for us to
make public (all of these will be implementation details of the
config system, including the config caching).

My answer to "why shouldn't the callbacks have <file, line>
information?" is "there is no reason why they shouldn't.  It is a
good addition in the long run".  But the optionality of the last
step in the above list makes it an irrelevant question.

  reply	other threads:[~2014-07-10 16:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 10:57 [PATCH v6 0/3] git config cache & special querying api utilizing the cache Tanay Abhra
2014-07-09 10:57 ` [PATCH v7 1/2] add `config_set` API for caching config-like files Tanay Abhra
2014-07-09 12:12   ` Matthieu Moy
2014-07-09 12:39     ` Tanay Abhra
2014-07-09 14:19       ` Matthieu Moy
2014-07-09 15:17         ` Junio C Hamano
2014-07-09 17:44           ` Junio C Hamano
2014-07-10  9:41             ` Matthieu Moy
2014-07-10 16:46               ` Junio C Hamano [this message]
2014-07-09 16:07         ` Tanay Abhra
2014-07-10 11:23           ` Matthieu Moy
2014-07-09 10:57 ` [PATCH v7 2/2] test-config: Add tests for the config_set API Tanay Abhra
2014-07-09 12:13   ` Matthieu Moy
2014-07-09 12:42     ` Tanay Abhra

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

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

  git send-email \
    --in-reply-to=xmqqvbr588mh.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tanayabh@gmail.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.