]> git.ipfire.org Git - thirdparty/git.git/blobdiff - config.c
Allow tracking branches to set up rebase by default.
[thirdparty/git.git] / config.c
index 062449459e1a4cfc2a605c065ed281669e0e7452..cf2bfd35c8394579beed8fa565bfcfe33dbd7540 100644 (file)
--- a/config.c
+++ b/config.c
@@ -303,8 +303,9 @@ unsigned long git_config_ulong(const char *name, const char *value)
        return ret;
 }
 
-int git_config_bool(const char *name, const char *value)
+int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
 {
+       *is_bool = 1;
        if (!value)
                return 1;
        if (!*value)
@@ -313,7 +314,14 @@ int git_config_bool(const char *name, const char *value)
                return 1;
        if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
                return 0;
-       return git_config_int(name, value) != 0;
+       *is_bool = 0;
+       return git_config_int(name, value);
+}
+
+int git_config_bool(const char *name, const char *value)
+{
+       int discard;
+       return !!git_config_bool_or_int(name, value, &discard);
 }
 
 int git_config_string(const char **dest, const char *var, const char *value)
@@ -479,6 +487,21 @@ int git_default_config(const char *var, const char *value)
                git_branch_track = git_config_bool(var, value);
                return 0;
        }
+       if (!strcmp(var, "branch.autosetuprebase")) {
+               if (!value)
+                       return config_error_nonbool(var);
+               else if (!strcmp(value, "never"))
+                       autorebase = AUTOREBASE_NEVER;
+               else if (!strcmp(value, "local"))
+                       autorebase = AUTOREBASE_LOCAL;
+               else if (!strcmp(value, "remote"))
+                       autorebase = AUTOREBASE_REMOTE;
+               else if (!strcmp(value, "always"))
+                       autorebase = AUTOREBASE_ALWAYS;
+               else
+                       return error("Malformed value for %s", var);
+               return 0;
+       }
 
        /* Add other config variables here and to Documentation/config.txt. */
        return 0;