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

[PATCH 4/6] Add "const" qualifier to "char *editor_program".

From
Christian Couder <chriscool@tuxfamily.org>
Date
Feb 16, 2008, 05:01 UTC
Message-ID
<20080216060141.53c0634b.chriscool@tuxfamily.org>

Also use "git_config_string" to simplify "config.c" code where "editor_program" is set.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 cache.h       |    2 +-
 config.c      |    8 ++------
 environment.c |    2 +-
 3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/cache.h b/cache.h
index 892f374..2af1468 100644
--- a/cache.h
+++ b/cache.h
@@ -655,7 +655,7 @@ extern const char *pager_program;
 extern int pager_in_use(void);
 extern int pager_use_color;
 
-extern char *editor_program;
+extern const char *editor_program;
 extern char *excludes_file;
 
 /* base85 */
diff --git a/config.c b/config.c
index 01e3843..07027de 100644
--- a/config.c
+++ b/config.c
@@ -443,12 +443,8 @@ int git_default_config(const char *var, const char *value)
 	if (!strcmp(var, "core.pager"))
 		return git_config_string(&pager_program, var, value);
 
-	if (!strcmp(var, "core.editor")) {
-		if (!value)
-			return config_error_nonbool(var);
-		editor_program = xstrdup(value);
-		return 0;
-	}
+	if (!strcmp(var, "core.editor"))
+		return git_config_string(&editor_program, var, value);
 
 	if (!strcmp(var, "core.excludesfile")) {
 		if (!value)
diff --git a/environment.c b/environment.c
index b8869e9..9556009 100644
--- a/environment.c
+++ b/environment.c
@@ -32,7 +32,7 @@ size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 16 * 1024 * 1024;
 const char *pager_program;
 int pager_use_color = 1;
-char *editor_program;
+const char *editor_program;
 char *excludes_file;
 int auto_crlf = 0;	/* 1: both ways, -1: only when adding git objects */
 unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
-- 
1.5.4.1.129.gf12af-dirty
Message 1 of 1 in “Add "const" qualifier to "char *editor_program".”
  1. 4/6 Add "const" qualifier to "char *editor_program".Christian Couder, Feb 16, 2008

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.