Skip to content

Commit 5a8a41a

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 151f343 commit 5a8a41a

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

compat/mingw.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ static int ask_yes_no_if_possible(const char *format, ...)
202202
}
203203
}
204204

205+
int mingw_core_config(const char *var, const char *value)
206+
{
207+
return 0;
208+
}
209+
205210
int mingw_unlink(const char *pathname)
206211
{
207212
int ret, tries = 0;

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
@@ -1008,7 +1008,7 @@ static int git_default_core_config(const char *var, const char *value)
10081008
}
10091009

10101010
/* Add other config variables here and to Documentation/config.txt. */
1011-
return 0;
1011+
return platform_core_config(var, value);
10121012
}
10131013

10141014
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
@@ -330,6 +330,14 @@ extern char *gitdirname(char *);
330330
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
331331
#endif
332332

333+
#ifndef platform_core_config
334+
static inline int noop_core_config(const char *var, const char *value)
335+
{
336+
return 0;
337+
}
338+
#define platform_core_config noop_core_config
339+
#endif
340+
333341
#ifndef has_dos_drive_prefix
334342
static inline int git_has_dos_drive_prefix(const char *path)
335343
{

0 commit comments

Comments
 (0)