From ea5105a5e3c6629ee64b499ea918c2b80882fc22 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:00:24 +0100 Subject: config: add 'git_config_string' to refactor string config variables. In many places we just check if a value from the config file is not NULL, then we duplicate it and return 0. This patch introduces the new 'git_config_string' function to do that. This function is also used to refactor some code in 'config.c'. Refactoring other files is left for other patches. Also not all the code in "config.c" is refactored, because the function takes a "const char **" as its first parameter, but in many places a "char *" is used instead of a "const char *". (And C does not allow using a "char **" instead of a "const char **" without a warning.) Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- cache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 6abcee437..c83b123fa 100644 --- a/cache.h +++ b/cache.h @@ -584,6 +584,7 @@ extern int git_parse_ulong(const char *, unsigned long *); extern int git_config_int(const char *, const char *); extern unsigned long git_config_ulong(const char *, const char *); extern int git_config_bool(const char *, const char *); +extern int git_config_string(const char **, const char *, const char *); extern int git_config_set(const char *, const char *); extern int git_config_set_multivar(const char *, const char *, const char *, int); extern int git_config_rename_section(const char *, const char *); -- cgit v1.2.1 From 872da32d80c004c26a19a5d6cb31eb3e7f034094 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:01:11 +0100 Subject: Add "const" qualifier to "char *pager_program". Also use "git_config_string" to simplify "config.c" code where "pager_program" is set. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cache.h') diff --git a/cache.h b/cache.h index c83b123fa..1ecaef14c 100644 --- a/cache.h +++ b/cache.h @@ -610,7 +610,7 @@ extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char /* pager.c */ extern void setup_pager(void); -extern char *pager_program; +extern const char *pager_program; extern int pager_in_use(void); extern int pager_use_color; -- cgit v1.2.1 From ee9601e6bef2281e3183e127e1e4e36ed257af7a Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:01:41 +0100 Subject: Add "const" qualifier to "char *editor_program". Also use "git_config_string" to simplify "config.c" code where "editor_program" is set. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 1ecaef14c..ce7b386a4 100644 --- a/cache.h +++ b/cache.h @@ -614,7 +614,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 */ -- cgit v1.2.1 From dfb068be8deef2065970b2a7889acc51abf4dd78 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:01:59 +0100 Subject: Add "const" qualifier to "char *excludes_file". Also use "git_config_string" to simplify "config.c" code where "excludes_file" is set. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cache.h') diff --git a/cache.h b/cache.h index ce7b386a4..43ba6a3ba 100644 --- a/cache.h +++ b/cache.h @@ -615,7 +615,7 @@ extern int pager_in_use(void); extern int pager_use_color; extern const char *editor_program; -extern char *excludes_file; +extern const char *excludes_file; /* base85 */ int decode_85(char *dst, const char *line, int linelen); -- cgit v1.2.1