diff options
| author | Sven Strickroth <email@cs-ware.de> | 2012-09-29 20:26:33 +0200 |
|---|---|---|
| committer | Sven Strickroth <email@cs-ware.de> | 2012-09-29 20:26:33 +0200 |
| commit | 32a4e3b712b2b63837afc28ebc9ba0169a0ac644 (patch) | |
| tree | afff1fce24cc61ab60e175cf99757ac54ac51bc1 /src/fileops.c | |
| parent | 549ee21a6f60baabf33b32b0d407957b4894d4aa (diff) | |
| download | libgit2-32a4e3b712b2b63837afc28ebc9ba0169a0ac644.tar.gz | |
Move code to find msysgit path using registry to own method
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/fileops.c b/src/fileops.c index 846025182..2a2324a7f 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -514,11 +514,9 @@ int find_system_file_using_path(git_buf *path, const char *filename) return GIT_ENOTFOUND; } -#endif -int git_futils_find_system_file(git_buf *path, const char *filename) +int find_system_file_using_registry(git_buf *path, const char *filename) { -#ifdef GIT_WIN32 #ifndef _WIN64 #define REG_MSYSGIT_INSTALL L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1" #else @@ -531,10 +529,6 @@ int git_futils_find_system_file(git_buf *path, const char *filename) DWORD dwType = REG_SZ; DWORD dwSize = MAX_PATH; - // try to find git.exe/git.cmd on path - if (!find_system_file_using_path(path, filename)) - return 0; - root.len = 0; if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, REG_MSYSGIT_INSTALL, 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) { @@ -563,18 +557,30 @@ int git_futils_find_system_file(git_buf *path, const char *filename) } return 0; +} +#endif +int git_futils_find_system_file(git_buf *path, const char *filename) +{ +#ifdef GIT_WIN32 + // try to find git.exe/git.cmd on path + if (!find_system_file_using_path(path, filename)) + return 0; + + // try to find msysgit installation path using registry + if (!find_system_file_using_registry(path, filename)) + return 0; #else if (git_buf_joinpath(path, "/etc", filename) < 0) return -1; if (git_path_exists(path->ptr) == true) return 0; +#endif git_buf_clear(path); giterr_set(GITERR_OS, "The system file '%s' doesn't exist", filename); return GIT_ENOTFOUND; -#endif } int git_futils_find_global_file(git_buf *path, const char *filename) |
