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

[RFC PATCH 5/7] config: make `scope_name` global as `config_scope_name`

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Jan 24, 2020, 09:25 UTC
Message-ID
<00742e5cd2d5b44c256be3b14fd2dd07e306ffdf.1579857394.git.bert.wesarg@googlemail.com>
In-Reply-To
<cover.1579857394.git.bert.wesarg@googlemail.com>
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
Will be replaced by Matthew Rogers.
Cc: Matthew Rogers <mattr94@gmail.com>
---
 config.c               | 16 ++++++++++++++++
 config.h               |  1 +
 t/helper/test-config.c | 17 +----------------
 3 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/config.c b/config.c
index d75f88ca0c..4c461bb7a3 100644
--- a/config.c
+++ b/config.c
@@ -3317,6 +3317,22 @@ enum config_scope current_config_scope(void)
 		return current_parsing_scope;
 }
 
+const char *config_scope_name(enum config_scope scope)
+{
+	switch (scope) {
+	case CONFIG_SCOPE_SYSTEM:
+		return "system";
+	case CONFIG_SCOPE_GLOBAL:
+		return "global";
+	case CONFIG_SCOPE_REPO:
+		return "repo";
+	case CONFIG_SCOPE_CMDLINE:
+		return "cmdline";
+	default:
+		return "unknown";
+	}
+}
+
 int lookup_config(const char **mapping, int nr_mapping, const char *var)
 {
 	int i;
diff --git a/config.h b/config.h
index 91fd4c5e96..c063f33ff6 100644
--- a/config.h
+++ b/config.h
@@ -301,6 +301,7 @@ enum config_scope {
 	CONFIG_SCOPE_REPO,
 	CONFIG_SCOPE_CMDLINE,
 };
+const char *config_scope_name(enum config_scope scope);
 
 enum config_scope current_config_scope(void);
 const char *current_config_origin_type(void);
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 214003d5b2..1e3bc7c8f4 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -37,21 +37,6 @@
  *
  */
 
-static const char *scope_name(enum config_scope scope)
-{
-	switch (scope) {
-	case CONFIG_SCOPE_SYSTEM:
-		return "system";
-	case CONFIG_SCOPE_GLOBAL:
-		return "global";
-	case CONFIG_SCOPE_REPO:
-		return "repo";
-	case CONFIG_SCOPE_CMDLINE:
-		return "cmdline";
-	default:
-		return "unknown";
-	}
-}
 static int iterate_cb(const char *var, const char *value, void *data)
 {
 	static int nr;
@@ -63,7 +48,7 @@ static int iterate_cb(const char *var, const char *value, void *data)
 	printf("value=%s\n", value ? value : "(null)");
 	printf("origin=%s\n", current_config_origin_type());
 	printf("name=%s\n", current_config_name());
-	printf("scope=%s\n", scope_name(current_config_scope()));
+	printf("scope=%s\n", config_scope_name(current_config_scope()));
 
 	return 0;
 }
-- 
2.24.1.497.g9abd7b20b4.dirty
Previous: Bert WesargNext: Bert Wesarg
Message 5 of 14 in “remote rename/remove: improve handling of configuration values”
  1. 0/7 remote rename/remove: improve handling of configuration valuesBert Wesarg, Jan 24, 2020
  2. 2/7 remote: clean-up by returning early to avoid one indentationBert Wesarg, Jan 24, 2020
  3. 1/7 pull --rebase/remote rename: document and honor single-letter abbreviations rebase typesBert Wesarg, Jan 24, 2020
  4. 3/7 remote: clean-up config callbackBert Wesarg, Jan 24, 2020
  5. 5/7 config: make `scope_name` global as `config_scope_name`Bert Wesarg, Jan 24, 2020
  6. 4/7 remote rename/remove: handle branch.<name>.pushRemote config valuesBert Wesarg, Jan 24, 2020
  7. Johannes SchindelinJan 25, 2020
  8. Bert WesargJan 25, 2020
  9. Johannes SchindelinJan 26, 2020
  10. 7/7 remote rename/remove: gently handle remote.pushDefault configBert Wesarg, Jan 24, 2020
  11. 6/7 config: provide access to the current line numberBert Wesarg, Jan 24, 2020
  12. Junio C HamanoJan 24, 2020
  13. Matt RogersJan 25, 2020
  14. Bert WesargJan 27, 2020

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.