mirror of
https://github.com/git-for-windows/git.git
synced 2026-05-03 12:26:23 -05:00
Merge branch 'mingw-home'
The environment variable `HOME` is not exactly a native concept on Windows, but Git and its scripts rely heavily on it. Make sure that it is set (using a default that is sensible in most cases, and can easily be overridden by setting the user-wide environment variable `HOME` explicitly, before starting Git). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -2364,6 +2364,30 @@ static void setup_windows_environment(void)
|
||||
/* simulate TERM to enable auto-color (see color.c) */
|
||||
if (!getenv("TERM"))
|
||||
setenv("TERM", "cygwin", 1);
|
||||
|
||||
/* calculate HOME if not set */
|
||||
if (!getenv("HOME")) {
|
||||
/*
|
||||
* try $HOMEDRIVE$HOMEPATH - the home share may be a network
|
||||
* location, thus also check if the path exists (i.e. is not
|
||||
* disconnected)
|
||||
*/
|
||||
if ((tmp = getenv("HOMEDRIVE"))) {
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
strbuf_addstr(&buf, tmp);
|
||||
if ((tmp = getenv("HOMEPATH"))) {
|
||||
strbuf_addstr(&buf, tmp);
|
||||
if (is_directory(buf.buf))
|
||||
setenv("HOME", buf.buf, 1);
|
||||
else
|
||||
tmp = NULL; /* use $USERPROFILE */
|
||||
}
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
/* use $USERPROFILE if the home share is not available */
|
||||
if (!tmp && (tmp = getenv("USERPROFILE")))
|
||||
setenv("HOME", tmp, 1);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
|
||||
Reference in New Issue
Block a user