Skip to content

Commit 70fc579

Browse files
dschogitster
authored andcommitted
config: 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]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 409670f commit 70fc579

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

compat/mingw.c

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

206+
int mingw_core_config(const char *var, const char *value, void *cb)
207+
{
208+
return 0;
209+
}
210+
206211
/* Normalizes NT paths as returned by some low-level APIs. */
207212
static wchar_t *normalize_ntpath(wchar_t *wbuf)
208213
{

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, void *cb);
15+
#define platform_core_config mingw_core_config
16+
1417
/*
1518
* things that are not available in header files
1619
*/

config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ int git_config_color(char *dest, const char *var, const char *value)
10931093
return 0;
10941094
}
10951095

1096-
static int git_default_core_config(const char *var, const char *value)
1096+
static int git_default_core_config(const char *var, const char *value, void *cb)
10971097
{
10981098
/* This needs a better name */
10991099
if (!strcmp(var, "core.filemode")) {
@@ -1363,7 +1363,7 @@ static int git_default_core_config(const char *var, const char *value)
13631363
}
13641364

13651365
/* Add other config variables here and to Documentation/config.txt. */
1366-
return 0;
1366+
return platform_core_config(var, value, cb);
13671367
}
13681368

13691369
static int git_default_i18n_config(const char *var, const char *value)
@@ -1451,7 +1451,7 @@ static int git_default_mailmap_config(const char *var, const char *value)
14511451
int git_default_config(const char *var, const char *value, void *cb)
14521452
{
14531453
if (starts_with(var, "core."))
1454-
return git_default_core_config(var, value);
1454+
return git_default_core_config(var, value, cb);
14551455

14561456
if (starts_with(var, "user."))
14571457
return git_ident_config(var, value, cb);

git-compat-util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ typedef uintmax_t timestamp_t;
342342
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
343343
#endif
344344

345+
#ifndef platform_core_config
346+
static inline int noop_core_config(const char *var, const char *value, void *cb)
347+
{
348+
return 0;
349+
}
350+
#define platform_core_config noop_core_config
351+
#endif
352+
345353
#ifndef has_dos_drive_prefix
346354
static inline int git_has_dos_drive_prefix(const char *path)
347355
{

0 commit comments

Comments
 (0)