From 4bf07f0430e7d68f81fdb1b22992154b0fe0d428 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 17 Nov 2016 17:24:10 +0100 Subject: [PATCH] Allow for platform-specific core.* config settings In the Git for Windows project, we have ample precendent for config settings that apply to Windows, and to Windows only. Let's formalize this concept by introducing a platform_core_config() function that can be #define'd in a platform-specific manner. This will allow us to contain platform-specific code better, as the corresponding variables no longer need to be exported so that they can be defined in environment.c and be set in config.c Signed-off-by: Johannes Schindelin --- compat/mingw.c | 4 ++++ compat/mingw.h | 3 +++ config.c | 2 +- git-compat-util.h | 8 ++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index fbb02f078d..cb6ed58bd5 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -228,6 +228,10 @@ static int retry_ask_yes_no(int *tries, const char *format, ...) return result; } +int mingw_core_config(const char *var, const char *value) +{ + return 0; +} DECLARE_PROC_ADDR(kernel32.dll, BOOL, CreateSymbolicLinkW, LPCWSTR, LPCWSTR, DWORD); diff --git a/compat/mingw.h b/compat/mingw.h index 49b7bb37e7..053accf035 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -11,6 +11,9 @@ typedef _sigset_t sigset_t; #undef _POSIX_THREAD_SAFE_FUNCTIONS #endif +extern int mingw_core_config(const char *var, const char *value); +#define platform_core_config mingw_core_config + /* * things that are not available in header files */ diff --git a/config.c b/config.c index 9defdf27a0..1b213c0040 100644 --- a/config.c +++ b/config.c @@ -1018,7 +1018,7 @@ static int git_default_core_config(const char *var, const char *value) } /* Add other config variables here and to Documentation/config.txt. */ - return 0; + return platform_core_config(var, value); } static int git_default_i18n_config(const char *var, const char *value) diff --git a/git-compat-util.h b/git-compat-util.h index 7b3b7e3084..1781b9ec72 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -367,6 +367,14 @@ static inline size_t msvc_iconv(iconv_t conv, #define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin" #endif +#ifndef platform_core_config +static inline int noop_core_config(const char *var, const char *value) +{ + return 0; +} +#define platform_core_config noop_core_config +#endif + #ifndef has_dos_drive_prefix static inline int git_has_dos_drive_prefix(const char *path) {