Merge branch 'jk/clone-dissociate' into maint
[gitweb.git] / config.c
index 66c0a51bce529e4c027f11017697a62dd737b3bd..286907b97e5a378e2be9677ee5b6a4fe7f6169af 100644 (file)
--- a/config.c
+++ b/config.c
@@ -12,6 +12,7 @@
 #include "quote.h"
 #include "hashmap.h"
 #include "string-list.h"
+#include "utf8.h"
 
 struct config_source {
        struct config_source *prev;
@@ -417,8 +418,7 @@ static int git_parse_source(config_fn_t fn, void *data)
        struct strbuf *var = &cf->var;
 
        /* U+FEFF Byte Order Mark in UTF8 */
-       static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
-       const unsigned char *bomptr = utf8_bom;
+       const char *bomptr = utf8_bom;
 
        for (;;) {
                int c = get_next_char();
@@ -426,7 +426,7 @@ static int git_parse_source(config_fn_t fn, void *data)
                        /* We are at the file beginning; skip UTF8-encoded BOM
                         * if present. Sane editors won't put this in on their
                         * own, but e.g. Windows Notepad will do it happily. */
-                       if ((unsigned char) c == *bomptr) {
+                       if (c == (*bomptr & 0377)) {
                                bomptr++;
                                continue;
                        } else {
@@ -1185,10 +1185,8 @@ int git_config_system(void)
 int git_config_early(config_fn_t fn, void *data, const char *repo_config)
 {
        int ret = 0, found = 0;
-       char *xdg_config = NULL;
-       char *user_config = NULL;
-
-       home_config_paths(&user_config, &xdg_config, "config");
+       char *xdg_config = xdg_config_home("config");
+       char *user_config = expand_user_path("~/.gitconfig");
 
        if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) {
                ret += git_config_from_file(fn, git_etc_gitconfig(),