diff options
author | Sven Strickroth <email@cs-ware.de> | 2012-09-24 18:02:47 +0200 |
---|---|---|
committer | Sven Strickroth <email@cs-ware.de> | 2012-09-24 18:02:47 +0200 |
commit | aed8f8a101872e8b4c81de788a5e675c67b50d20 (patch) | |
tree | b677f402c96ad152c9c284701998c8f5baba1ef4 /src/fileops.c | |
parent | 63f6c82568419848e726ae6373d2ba03de0621fd (diff) | |
download | libgit2-aed8f8a101872e8b4c81de788a5e675c67b50d20.tar.gz |
Honor %HOME% on windows
Use %HOME% before trying to figure out the windows user directory.
Users might set this as they are used on *nix systems.
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Diffstat (limited to 'src/fileops.c')
-rw-r--r-- | src/fileops.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/fileops.c b/src/fileops.c index 8ccf063d5..d85ff7c72 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -455,9 +455,20 @@ int git_futils_find_system_file(git_buf *path, const char *filename) int git_futils_find_global_file(git_buf *path, const char *filename) { + const char *home = getenv("HOME"); + #ifdef GIT_WIN32 struct win32_path root; + if (home != NULL) { + if (git_buf_joinpath(path, home, filename) < 0) + return -1; + + if (git_path_exists(path->ptr)) { + return 0; + } + } + if (win32_expand_path(&root, L"%USERPROFILE%\\") < 0 || root.path[0] == L'%') /* i.e. no expansion happened */ { @@ -473,8 +484,6 @@ int git_futils_find_global_file(git_buf *path, const char *filename) return 0; #else - const char *home = getenv("HOME"); - if (home == NULL) { giterr_set(GITERR_OS, "Global file lookup failed. " "Cannot locate the user's home directory"); |