Closed linquize closed 9 years ago
MSysGit - the development behind Git for Windows » git #264 SUCCESS This pull request looks good (what's this?)
Changed to use is_directory()
Thank you so much!
My only remaining request is to adjust the commit message a bit. The idea is that we contribute all of the modifications of the Git source code to upstream, eventually, therefore it would be good to abide by their rules. Would you please prefix the patch by mingw:
, make sure that the first line is shorter than 73 characters, and maybe mention in the commit message's body why we go through such a dance with the HOME
variable? Oh, and please sign off on the patch, as described here.
MSysGit - the development behind Git for Windows » git #266 SUCCESS This pull request looks good (what's this?)
Commit message updated.
MSysGit - the development behind Git for Windows » git #267 FAILURE Looks like there's a problem with this pull request (what's this?)
Thank you so much!
Good intentions - unfortunately, you've based your change on code that is not in the master branch.
Rather than fixing any of the pre-existing issues with get_windows_home_directory()
discussed in [1], you've added quite a few more:
is_directory(NULL)
(or rather: stat(NULL)
) is undefined. Why remove the NULL-checks?get_windows_home_directory()
is a replacement for getenv("HOME")
, so it should not set errno (but is_directory()
does)is_directory()
if HOME has already been properly set by the parent process? Hitting the file system (three times!) will slow down startup of every git process, especially if $HOMEDRIVE is disconnected. And scripted commands launch a lot of processes...get_windows_home_directory()
is no longer thread-safe, i.e. a thread may see an incompletely initialized value of the home_directory
variableTo set "HOME" in git, I would have expected something like this on master:
@@ -2239,6 +2239,27 @@ void mingw_startup()
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 (getenv("HOMEDRIVE") && getenv("HOMEPATH")) {
+ struct strbuf buf = STRBUF_INIT;
+ strbuf_addf(&buf, "%s%s", getenv("HOMEDRIVE"),
+ getenv("HOMEPATH"));
+ if (is_directory(buf.buf))
+ setenv("HOME", buf.buf, 1);
+ strbuf_release(&buf);
+ }
+
+ /* use $USERPROFILE if the home share is not available */
+ if (!getenv("HOME") && getenv("USERPROFILE"))
+ setenv("HOME", getenv("USERPROFILE"), 1);
+ }
+
/* initialize critical section for waitpid pinfo_t list */
InitializeCriticalSection(&pinfo_cs);
[1] https://groups.google.com/forum/#!topic/msysgit/wmyWC6M2hl4
For git.exe alone, use the same HOME directory fallback mechanism as /etc/profile
This allows the fallback mechanism to work outside Git Bash.