diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-05-23 11:51:00 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-10-09 11:19:42 +0200 |
commit | 529e873cef18ec98246d32d28c7a0b0e3467fe27 (patch) | |
tree | f810490f62966f39ea9c86e041b8102956d2306f /include/git2/sys | |
parent | d02cf564a012ea8f6d4d4fd70a3102b94058f759 (diff) | |
download | libgit2-529e873cef18ec98246d32d28c7a0b0e3467fe27.tar.gz |
config: pass repository when opening config files
Our current configuration logic is completely oblivious of any
repository, but only cares for actual file paths. Unfortunately, we are
forced to break this assumption by the introduction of conditional
includes, which are evaluated in the context of a repository. Right now,
only one conditional exists with "gitdir:" -- it will only include the
configuration if the current repository's git directory matches the
value passed to "gitdir:".
To support these conditionals, we have to break our API and make the
repository available when opening a configuration file. This commit
extends the `open` call of configuration backends to include another
repository and adjusts existing code to have it available. This includes
the user-visible functions `git_config_add_file_ondisk` and
`git_config_add_backend`.
Diffstat (limited to 'include/git2/sys')
-rw-r--r-- | include/git2/sys/config.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h index 4dad6da42..ed203226f 100644 --- a/include/git2/sys/config.h +++ b/include/git2/sys/config.h @@ -58,7 +58,7 @@ struct git_config_backend { struct git_config *cfg; /* Open means open the file/database and parse if necessary */ - int (*open)(struct git_config_backend *, git_config_level_t level); + int (*open)(struct git_config_backend *, git_config_level_t level, const git_repository *repo); int (*get)(struct git_config_backend *, const char *key, git_config_entry **entry); int (*set)(struct git_config_backend *, const char *key, const char *value); int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value); @@ -111,6 +111,8 @@ GIT_EXTERN(int) git_config_init_backend( * @param cfg the configuration to add the file to * @param file the configuration file (backend) to add * @param level the priority level of the backend + * @param repo optional repository to allow parsing of + * conditional includes * @param force if a config file already exists for the given * priority level, replace it * @return 0 on success, GIT_EEXISTS when adding more than one file @@ -120,6 +122,7 @@ GIT_EXTERN(int) git_config_add_backend( git_config *cfg, git_config_backend *file, git_config_level_t level, + const git_repository *repo, int force); /** @} */ |