git-remote-mediawiki: show progress information when getting last remote revision
[git.git] / config.c
index ac69cb62935cfe86fec4b557ad6546366e6b7d70..40818e872ffb61e725d63e0bbf1424ea8987009c 100644 (file)
--- a/config.c
+++ b/config.c
@@ -758,25 +758,8 @@ static int git_default_core_config(const char *var, const char *value)
                return 0;
        }
 
-       /* Add other config variables here and to Documentation/config.txt. */
-       return 0;
-}
-
-static int git_default_user_config(const char *var, const char *value)
-{
-       if (!strcmp(var, "user.name")) {
-               if (!value)
-                       return config_error_nonbool(var);
-               strlcpy(git_default_name, value, sizeof(git_default_name));
-               user_ident_explicitly_given |= IDENT_NAME_GIVEN;
-               return 0;
-       }
-
-       if (!strcmp(var, "user.email")) {
-               if (!value)
-                       return config_error_nonbool(var);
-               strlcpy(git_default_email, value, sizeof(git_default_email));
-               user_ident_explicitly_given |= IDENT_MAIL_GIVEN;
+       if (!strcmp(var, "core.precomposeunicode")) {
+               precomposed_unicode = git_config_bool(var, value);
                return 0;
        }
 
@@ -835,6 +818,8 @@ static int git_default_push_config(const char *var, const char *value)
                        push_default = PUSH_DEFAULT_NOTHING;
                else if (!strcmp(value, "matching"))
                        push_default = PUSH_DEFAULT_MATCHING;
+               else if (!strcmp(value, "simple"))
+                       push_default = PUSH_DEFAULT_SIMPLE;
                else if (!strcmp(value, "upstream"))
                        push_default = PUSH_DEFAULT_UPSTREAM;
                else if (!strcmp(value, "tracking")) /* deprecated */
@@ -843,8 +828,8 @@ static int git_default_push_config(const char *var, const char *value)
                        push_default = PUSH_DEFAULT_CURRENT;
                else {
                        error("Malformed value for %s: %s", var, value);
-                       return error("Must be one of nothing, matching, "
-                                    "tracking or current.");
+                       return error("Must be one of nothing, matching, simple, "
+                                    "upstream or current.");
                }
                return 0;
        }
@@ -868,7 +853,7 @@ int git_default_config(const char *var, const char *value, void *dummy)
                return git_default_core_config(var, value);
 
        if (!prefixcmp(var, "user."))
-               return git_default_user_config(var, value);
+               return git_ident_config(var, value, dummy);
 
        if (!prefixcmp(var, "i18n."))
                return git_default_i18n_config(var, value);
@@ -949,7 +934,10 @@ int git_config_system(void)
 int git_config_early(config_fn_t fn, void *data, const char *repo_config)
 {
        int ret = 0, found = 0;
-       const char *home = NULL;
+       char *xdg_config = NULL;
+       char *user_config = NULL;
+
+       home_config_paths(&user_config, &xdg_config, "config");
 
        if (git_config_system() && !access(git_etc_gitconfig(), R_OK)) {
                ret += git_config_from_file(fn, git_etc_gitconfig(),
@@ -957,14 +945,14 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
                found += 1;
        }
 
-       home = getenv("HOME");
-       if (home) {
-               char buf[PATH_MAX];
-               char *user_config = mksnpath(buf, sizeof(buf), "%s/.gitconfig", home);
-               if (!access(user_config, R_OK)) {
-                       ret += git_config_from_file(fn, user_config, data);
-                       found += 1;
-               }
+       if (!access(xdg_config, R_OK)) {
+               ret += git_config_from_file(fn, xdg_config, data);
+               found += 1;
+       }
+
+       if (!access(user_config, R_OK)) {
+               ret += git_config_from_file(fn, user_config, data);
+               found += 1;
        }
 
        if (repo_config && !access(repo_config, R_OK)) {
@@ -983,6 +971,8 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
                break;
        }
 
+       free(xdg_config);
+       free(user_config);
        return ret == 0 ? found : ret;
 }