config: read config from a repository object
Teach the config machinery to read config information from a repository object. This involves storing a 'struct config_set' inside the repository object and adding a number of functions (repo_config*) to be able to query a repository's config. The current config API enables lazy-loading of the config. This means that when 'git_config_get_int()' is called, if the_config_set hasn't been populated yet, then it will be populated and properly initialized by reading the necessary config files (system wide .gitconfig, user's home .gitconfig, and the repository's config). To maintain this paradigm, the new API to read from a repository object's config will also perform this lazy-initialization. Since both APIs (git_config_get* and repo_config_get*) have the same semantics we can migrate the default config to be stored within 'the_repository' and just have the 'git_config_get*' family of functions redirect to the 'repo_config_get*' functions. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
b42b0c0919
commit
3b256228a6
24
config.h
24
config.h
@ -163,6 +163,30 @@ extern int git_configset_get_bool_or_int(struct config_set *cs, const char *key,
|
||||
extern int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *dest);
|
||||
extern int git_configset_get_pathname(struct config_set *cs, const char *key, const char **dest);
|
||||
|
||||
/* Functions for reading a repository's config */
|
||||
struct repository;
|
||||
extern void repo_config(struct repository *repo, config_fn_t fn, void *data);
|
||||
extern int repo_config_get_value(struct repository *repo,
|
||||
const char *key, const char **value);
|
||||
extern const struct string_list *repo_config_get_value_multi(struct repository *repo,
|
||||
const char *key);
|
||||
extern int repo_config_get_string_const(struct repository *repo,
|
||||
const char *key, const char **dest);
|
||||
extern int repo_config_get_string(struct repository *repo,
|
||||
const char *key, char **dest);
|
||||
extern int repo_config_get_int(struct repository *repo,
|
||||
const char *key, int *dest);
|
||||
extern int repo_config_get_ulong(struct repository *repo,
|
||||
const char *key, unsigned long *dest);
|
||||
extern int repo_config_get_bool(struct repository *repo,
|
||||
const char *key, int *dest);
|
||||
extern int repo_config_get_bool_or_int(struct repository *repo,
|
||||
const char *key, int *is_bool, int *dest);
|
||||
extern int repo_config_get_maybe_bool(struct repository *repo,
|
||||
const char *key, int *dest);
|
||||
extern int repo_config_get_pathname(struct repository *repo,
|
||||
const char *key, const char **dest);
|
||||
|
||||
extern int git_config_get_value(const char *key, const char **value);
|
||||
extern const struct string_list *git_config_get_value_multi(const char *key);
|
||||
extern void git_config_clear(void);
|
||||
|
Reference in New Issue
Block a user