]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: allow for platform-specific core.* config settings
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 30 Oct 2018 18:40:04 +0000 (11:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 31 Oct 2018 03:46:21 +0000 (12:46 +0900)
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c
compat/mingw.h
config.c
git-compat-util.h

index 81ef24286a2757920e411b3858bcbdfd51d69a3b..293f286af1990566208d9a3b38503d9a3657edfb 100644 (file)
@@ -203,6 +203,11 @@ static int ask_yes_no_if_possible(const char *format, ...)
        }
 }
 
+int mingw_core_config(const char *var, const char *value, void *cb)
+{
+       return 0;
+}
+
 /* Normalizes NT paths as returned by some low-level APIs. */
 static wchar_t *normalize_ntpath(wchar_t *wbuf)
 {
index f31dcff2be1d60ce4f5ae46089d59255f1bc4dff..e9d2b9cdd3f13ddda77a9f7301067f4f7f127034 100644 (file)
@@ -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, void *cb);
+#define platform_core_config mingw_core_config
+
 /*
  * things that are not available in header files
  */
index 3687c6783ecc12ef4d8a14bf4f4bc47c7b47a9bd..646b6cca96b79bd557de18cbd2cc9bdb0c50c6e0 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1093,7 +1093,7 @@ int git_config_color(char *dest, const char *var, const char *value)
        return 0;
 }
 
-static int git_default_core_config(const char *var, const char *value)
+static int git_default_core_config(const char *var, const char *value, void *cb)
 {
        /* This needs a better name */
        if (!strcmp(var, "core.filemode")) {
@@ -1363,7 +1363,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, cb);
 }
 
 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)
 int git_default_config(const char *var, const char *value, void *cb)
 {
        if (starts_with(var, "core."))
-               return git_default_core_config(var, value);
+               return git_default_core_config(var, value, cb);
 
        if (starts_with(var, "user."))
                return git_ident_config(var, value, cb);
index 96a3f86d8e6991e19815008a3a6b8cebe95b1ca8..3a08d9916fb49b5a1578c74a5ae2949d98a8e699 100644 (file)
@@ -342,6 +342,14 @@ typedef uintmax_t timestamp_t;
 #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, void *cb)
+{
+       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)
 {