[PATCH 2/7] Add git_configset_add_standard

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This exposes implementation details of repo_read_config
so a configset can be populated with a repository's standard config,
without needing to create a full repository.

This allows config lookup to use the same codepath
whether the repository is ready or not,
which allows it to be used during git init.
---
 config.c | 7 ++++++-
 config.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/config.c b/config.c
index 231f9a7..d0af812 100644
--- a/config.c
+++ b/config.c
@@ -1764,6 +1764,11 @@ int git_configset_add_file(struct config_set *cs, const char *filename)
 	return git_config_from_file(config_set_callback, filename, cs);
 }
 
+int git_configset_add_standard(struct config_set *cs, const struct config_options *opts)
+{
+	return config_with_options(config_set_callback, cs, NULL, opts);
+}
+
 int git_configset_get_value(struct config_set *cs, const char *key, const char **value)
 {
 	const struct string_list *values = NULL;
@@ -1879,7 +1884,7 @@ static void repo_read_config(struct repository *repo)
 
 	git_configset_init(repo->config);
 
-	if (config_with_options(config_set_callback, repo->config, NULL, &opts) < 0)
+	if (git_configset_add_standard(repo->config, &opts) < 0)
 		/*
 		 * config_with_options() normally returns only
 		 * zero, as most errors are fatal, and
diff --git a/config.h b/config.h
index 0352da1..0b7b8d2 100644
--- a/config.h
+++ b/config.h
@@ -151,6 +151,7 @@ struct config_set {
 
 extern void git_configset_init(struct config_set *cs);
 extern int git_configset_add_file(struct config_set *cs, const char *filename);
+extern int git_configset_add_standard(struct config_set *cs, const struct config_options *opts);
 extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value);
 extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key);
 extern void git_configset_clear(struct config_set *cs);
-- 
2.9.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux