diff --git a/src/attrcache.c b/src/attrcache.c index 4df14ee2c..54161894b 100644 --- a/src/attrcache.c +++ b/src/attrcache.c @@ -290,14 +290,16 @@ static int attr_cache__lookup_path( const char *cfgval = entry->value; /* expand leading ~/ as needed */ - if (cfgval && cfgval[0] == '~' && cfgval[1] == '/' && - !git_sysdir_find_global_file(&buf, &cfgval[2])) - *out = git_buf_detach(&buf); - else if (cfgval) + if (cfgval && cfgval[0] == '~' && cfgval[1] == '/') { + if (! (error = git_sysdir_expand_global_file(&buf, &cfgval[2]))) + *out = git_buf_detach(&buf); + } else if (cfgval) { *out = git__strdup(cfgval); + } } - else if (!git_sysdir_find_xdg_file(&buf, fallback)) + else if (!git_sysdir_find_xdg_file(&buf, fallback)) { *out = git_buf_detach(&buf); + } git_config_entry_free(entry); git_buf_free(&buf); diff --git a/src/config_file.c b/src/config_file.c index 6ef80660a..5153f57d2 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -1254,16 +1254,8 @@ static int strip_comments(char *line, int in_quotes) static int included_path(git_buf *out, const char *dir, const char *path) { /* From the user's home */ - int result; - if (path[0] == '~' && path[1] == '/') { - result = git_sysdir_find_global_file(out, &path[1]); - if (result == GIT_ENOTFOUND) { - git_buf_sets(out, &path[1]); - return 0; - } - - return result; - } + if (path[0] == '~' && path[1] == '/') + return git_sysdir_expand_global_file(out, &path[1]); return git_path_join_unrooted(out, path, dir, NULL); }