mirror of
https://github.com/git/git.git
synced 2026-03-31 12:00:09 +02:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user