Commit e54d8d89 by Vicent Martí

error-handling: Config

parent cb8a7961
...@@ -126,6 +126,7 @@ typedef enum { ...@@ -126,6 +126,7 @@ typedef enum {
GITERR_REFERENCE, GITERR_REFERENCE,
GITERR_ZLIB, GITERR_ZLIB,
GITERR_REPOSITORY, GITERR_REPOSITORY,
GITERR_CONFIG,
} git_error_class; } git_error_class;
#define GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; } #define GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; }
......
...@@ -295,7 +295,6 @@ int git_futils_rmdir_r(const char *path, int force) ...@@ -295,7 +295,6 @@ int git_futils_rmdir_r(const char *path, int force)
int git_futils_find_global_file(git_buf *path, const char *filename) int git_futils_find_global_file(git_buf *path, const char *filename)
{ {
int error;
const char *home = getenv("HOME"); const char *home = getenv("HOME");
#ifdef GIT_WIN32 #ifdef GIT_WIN32
...@@ -303,19 +302,21 @@ int git_futils_find_global_file(git_buf *path, const char *filename) ...@@ -303,19 +302,21 @@ int git_futils_find_global_file(git_buf *path, const char *filename)
home = getenv("USERPROFILE"); home = getenv("USERPROFILE");
#endif #endif
if (home == NULL) if (home == NULL) {
return git__throw(GIT_EOSERR, "Failed to open global %s file. " giterr_set(GITERR_OS, "Global file lookup failed. "
"Cannot locate the user's home directory.", filename); "Cannot locate the user's home directory");
return -1;
}
if ((error = git_buf_joinpath(path, home, filename)) < GIT_SUCCESS) if (git_buf_joinpath(path, home, filename) < 0)
return error; return -1;
if (git_path_exists(path->ptr) == false) { if (git_path_exists(path->ptr) == false) {
git_buf_clear(path); git_buf_clear(path);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
return GIT_SUCCESS; return 0;
} }
#ifdef GIT_WIN32 #ifdef GIT_WIN32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment