diff options
author | Tanay Abhra <tanayabh@gmail.com> | 2014-07-28 03:10:38 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-29 14:29:56 -0700 |
commit | 3c8687a73eeffc21f5a0b3916d38e46ff985933d (patch) | |
tree | a05157ca1d860f3a72f4744e6e0c7761c48822e0 /setup.c | |
parent | 996b0fdbb4ff63bfd880b3901f054139c95611cf (diff) | |
download | git-3c8687a73eeffc21f5a0b3916d38e46ff985933d.tar.gz |
add `config_set` API for caching config-like files
Currently `git_config()` uses a callback mechanism and file rereads for
config values. Due to this approach, it is not uncommon for the config
files to be parsed several times during the run of a git program, with
different callbacks picking out different variables useful to themselves.
Add a `config_set`, that can be used to construct an in-memory cache for
config-like files that the caller specifies (i.e., files like `.gitmodules`,
`~/.gitconfig` etc.). Add two external functions `git_configset_get_value`
and `git_configset_get_value_multi` for querying from the config sets.
`git_configset_get_value` follows `last one wins` semantic (i.e. if there
are multiple matches for the queried key in the files of the configset the
value returned will be the last entry in `value_list`).
`git_configset_get_value_multi` returns a list of values sorted in order of
increasing priority (i.e. last match will be at the end of the list). Add
type specific query functions like `git_configset_get_bool` and similar.
Add a default `config_set`, `the_config_set` to cache all key-value pairs
read from usual config files (repo specific .git/config, user wide
~/.gitconfig, XDG config and the global /etc/gitconfig). `the_config_set`
is populated using `git_config()`.
Add two external functions `git_config_get_value` and
`git_config_get_value_multi` for querying in a non-callback manner from
`the_config_set`. Also, add type specific query functions that are
implemented as a thin wrapper around the `config_set` API.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'setup.c')
-rw-r--r-- | setup.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -625,6 +625,15 @@ static const char *setup_git_directory_gently_1(int *nongit_ok) int one_filesystem = 1; /* + * We may have read an incomplete configuration before + * setting-up the git directory. If so, clear the cache so + * that the next queries to the configuration reload complete + * configuration (including the per-repo config file that we + * ignored previously). + */ + git_config_clear(); + + /* * Let's assume that we are in a git repository. * If it turns out later that we are somewhere else, the value will be * updated accordingly. |