Skip to content

Commit e1f5156

Browse files
committed
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 <[email protected]>
1 parent 6f6239c commit e1f5156

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

compat/mingw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ static int retry_ask_yes_no(int *tries, const char *format, ...)
228228
return result;
229229
}
230230

231+
int mingw_core_config(const char *var, const char *value)
232+
{
233+
return 0;
234+
}
231235

232236
DECLARE_PROC_ADDR(kernel32.dll, BOOL, CreateSymbolicLinkW, LPCWSTR, LPCWSTR, DWORD);
233237

compat/mingw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ typedef _sigset_t sigset_t;
1111
#undef _POSIX_THREAD_SAFE_FUNCTIONS
1212
#endif
1313

14+
extern int mingw_core_config(const char *var, const char *value);
15+
#define platform_core_config mingw_core_config
16+
1417
/*
1518
* things that are not available in header files
1619
*/

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ static int git_default_core_config(const char *var, const char *value)
10181018
}
10191019

10201020
/* Add other config variables here and to Documentation/config.txt. */
1021-
return 0;
1021+
return platform_core_config(var, value);
10221022
}
10231023

10241024
static int git_default_i18n_config(const char *var, const char *value)

git-compat-util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,14 @@ static inline size_t msvc_iconv(iconv_t conv,
367367
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
368368
#endif
369369

370+
#ifndef platform_core_config
371+
static inline int noop_core_config(const char *var, const char *value)
372+
{
373+
return 0;
374+
}
375+
#define platform_core_config noop_core_config
376+
#endif
377+
370378
#ifndef has_dos_drive_prefix
371379
static inline int git_has_dos_drive_prefix(const char *path)
372380
{

0 commit comments

Comments
 (0)