Add a Windows-specific fallback to getenv("HOME");

This fixes msysGit issue 482 properly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2010-06-02 00:41:33 +02:00
parent 38ab7608d6
commit cefa4fe5e8
6 changed files with 29 additions and 4 deletions

View File

@@ -1726,3 +1726,21 @@ struct dirent *mingw_readdir(DIR *dir)
return (struct dirent*)&dir->dd_dir;
}
#endif // !NO_MINGW_REPLACE_READDIR
const char *get_windows_home_directory()
{
static const char *home_directory = NULL;
struct strbuf buf = STRBUF_INIT;
if (home_directory)
return home_directory;
home_directory = getenv("HOME");
if (home_directory && *home_directory)
return home_directory;
strbuf_addf(&buf, "%s/%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
home_directory = strbuf_detach(&buf, NULL);
return home_directory;
}

View File

@@ -337,3 +337,6 @@ struct dirent *mingw_readdir(DIR *dir);
* Used by Pthread API implementation for Windows
*/
extern int err_win_to_posix(DWORD winerr);
extern const char *get_windows_home_directory();
#define get_home_directory() get_windows_home_directory()