git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/7] Add git_configset_add_standard

From
Richard Maw <richard.maw@gmail.com>
Date
Aug 13, 2017, 19:36 UTC
Message-ID
<20170813193611.4233-3-richard.maw@gmail.com>
In-Reply-To
<20170813193611.4233-1-richard.maw@gmail.com>

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
Previous: Richard MawNext: Richard Maw
Message 3 of 13 in “Implement ref namespaces as a ref storage backend”
  1. 0/7 Implement ref namespaces as a ref storage backendRichard Maw, Aug 13, 2017
  2. 1/7 Expose expand_namespace APIRichard Maw, Aug 13, 2017
  3. 2/7 Add git_configset_add_standardRichard Maw, Aug 13, 2017
  4. 3/7 Add helper for skipping namespace prefixesRichard Maw, Aug 13, 2017
  5. 4/7 Autocreate reflogs for namespaced refsRichard Maw, Aug 13, 2017
  6. 5/7 Treat namespaced HEAD and refs/bisect as per-worktreeRichard Maw, Aug 13, 2017
  7. 6/7 Add namespaced ref backendRichard Maw, Aug 13, 2017
  8. 7/7 Plumb in namespaced ref storeRichard Maw, Aug 13, 2017
  9. Stefan BellerAug 14, 2017
  10. Junio C HamanoAug 15, 2017
  11. Richard MawAug 24, 2017
  12. Michael HaggertyAug 24, 2017
  13. Richard MawAug 30, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.