vendor/libgit2/src/sysdir.c in rugged-0.23.2 vs vendor/libgit2/src/sysdir.c in rugged-0.23.3
- old
+ new
@@ -27,41 +27,27 @@
static int git_sysdir_guess_global_dirs(git_buf *out)
{
#ifdef GIT_WIN32
return git_win32__find_global_dirs(out);
#else
- int error = git__getenv(out, "HOME");
-
- if (error == GIT_ENOTFOUND) {
- giterr_clear();
- error = 0;
- }
-
- return error;
+ return git_buf_sets(out, getenv("HOME"));
#endif
}
static int git_sysdir_guess_xdg_dirs(git_buf *out)
{
#ifdef GIT_WIN32
return git_win32__find_xdg_dirs(out);
#else
- git_buf env = GIT_BUF_INIT;
- int error;
+ const char *env = NULL;
- if ((error = git__getenv(&env, "XDG_CONFIG_HOME")) == 0)
- error = git_buf_joinpath(out, env.ptr, "git");
+ if ((env = getenv("XDG_CONFIG_HOME")) != NULL)
+ return git_buf_joinpath(out, env, "git");
+ else if ((env = getenv("HOME")) != NULL)
+ return git_buf_joinpath(out, env, ".config/git");
- if (error == GIT_ENOTFOUND && (error = git__getenv(&env, "HOME")) == 0)
- error = git_buf_joinpath(out, env.ptr, ".config/git");
-
- if (error == GIT_ENOTFOUND) {
- giterr_clear();
- error = 0;
- }
-
- git_buf_free(&env);
- return error;
+ git_buf_clear(out);
+ return 0;
#endif
}
static int git_sysdir_guess_template_dirs(git_buf *out)
{