From: Karsten Blees <karsten.blees@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Erik Faye-Lund <kusmabite@gmail.com>
Cc: Duy Nguyen <pclouds@gmail.com>, Stepan Kasal <kasal@ucw.cz>,
GIT Mailing-list <git@vger.kernel.org>,
Thomas Braun <thomas.braun@virtuell-zuhause.de>,
msysGit <msysgit@googlegroups.com>
Subject: Re: Re: [PATCH] Add a Windows-specific fallback to getenv("HOME");
Date: Thu, 05 Jun 2014 03:42:13 +0200 [thread overview]
Message-ID: <538FCAF5.7030102@gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.1406041741470.14982@s15462909.onlinehome-server.info>
Am 04.06.2014 17:46, schrieb Johannes Schindelin:
> Hi kusma,
>
> On Wed, 4 Jun 2014, Johannes Schindelin wrote:
>
>> The problem arises whenever git.exe calls subprocesses. You can pollute
>> the environment by setting HOME, I do not recall the details, but I
>> remember that we had to be very careful *not* to do that, hence the patch.
>> Sorry, has been a long time.
>
> Actually, a quick search in my Applegate vaults^W^Wmail archives suggests
> that we had tons of troubles with non-ASCII characters in the path.
>
After a bit of digging in the history and the old googlegroups issue tracker, I think this patch is completely unrelated to the non-ASCII problems.
In summary, this patch fixes 'git config' for the portable version only, and it only does so partially. Thus I don't think its ready for upstream, at least not in its current form. See below for the nasty details.
> I would be strongly
> in favor of fixing the problem by the root: avoiding to have Git rely on
> the HOME environment variable to be set, but instead add a clean API call
> that even says what it is supposed to do: gimme the user's home
> directory's path. And that is exactly what the patch does.
>
By that argument we'd have to introduce API abstractions for every environment variable that could possibly resemble a path (PATH, TMPDIR, GIT_DIR, GIT_WORK_DIR, GIT_TRACE* etc.).
We already have similar fallback logic for TMPDIR that is completely non-intrusive to core git code (fully encapsulated in mingw.c, see mingw_getenv (upstream) or mingw_startup (msysgit)). IMO such a solution would be hugely preferable over adding an additional get_home_directory() API (and continuously checking that no new upstream code accidentally introduces another 'getenv("HOME")').
Cheers,
Karsten
====
Analysis of $HOME-realted issues:
1. mangled non-ASCII characters in environment variables
E.g. issue 491 [1], reportedly fixed in v1.7.10 ([1] comment #10).
This is actually a bug in msys.dll, and there's nothing that can be done about it from within git.exe. It is also not a problem if git is launched from cmd.exe.
The root cause is that the msys environment is initialized using GetEnvironmentStringsA(), which returns GetOEMCP()-encoded strings (e.g. cp850), rather than GetACP() (e.g. cp1252) as all other *A API functions do [2]. This adds one level of mangling whenever a native Windows program starts an msys program (so e.g. the call chain bash->git->bash->wish would mangle twice, see [1] comment #3).
For the fixed GetEnvironmentStringsA(), see [3] lines 459ff.
(As a side note, $HOMEDRIVE and $HOMEPATH originally did not have this problem, as they were separately initialized from NetUserGetInfoA(). This was changed in v1.6.3, however, at that time etc/profile was still using the broken $USERPROFILE. See [4], [5].)
2. 'git config' doesn't work with disconnected network drives
Issues 259 [6], 497 [7] and 512 [8], fixed in v1.7.0.2 for bash and v1.7.2.3 for cmd.
Apparently, $HOMEDRIVE$HOMEPATH is the home directory on the network, and $USERPROFILE is local. To be able to work offline, we need to check if $HOMEDRIVE$HOMEPATH exists and fall back to $USERPROFILE otherwise.
Note that git-wrapper does _not_ check if $HOMEDRIVE$HOMEPATH actually exists, as the original git.cmd did. This is probably a regression wrt issue 259.
3. HOME is not set when using the portable version
Issue 482 [9], partially fixed in v1.7.2.3 by this patch.
'Partially' because:
- there's no fallback to $USERPROFILE, so it doesn't work with disconnected network drives (see problem 2.)
- it doesn't setenv(HOME) for child processes (at least git-gui accesses $env(HOME) directly, but I haven't checked what happens if HOME is not set)
Incidentally, this patch was first released with v1.7.2.3, which also sets $HOME correctly in both etc/profile and git.cmd. So I suspect that this patch has always been essentially dead code (except perhaps for the portable version, I've never used that).
[1] https://code.google.com/p/msysgit/issues/detail?id=491
[2] http://msdn.microsoft.com/en-us/library/windows/desktop/ms683187%28v=vs.85%29.aspx
[3] https://github.com/msysgit/msysgit/blob/msys/src/rt/patches/0013-msys.dll-basic-Unicode-support.patch
[4] https://github.com/msysgit/msysgit/blob/msys/src/rt/patches/0007-only-override-the-variables-HOMEPATH-and-HOMEDRIVE-i.patch
[5] https://github.com/msysgit/msysgit/commit/6b096c9
[6] https://code.google.com/p/msysgit/issues/detail?id=259
[7] https://code.google.com/p/msysgit/issues/detail?id=497
[8] https://code.google.com/p/msysgit/issues/detail?id=512
[9] https://code.google.com/p/msysgit/issues/detail?id=482
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
next prev parent reply other threads:[~2014-06-05 1:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 11:47 [PATCH] Add a Windows-specific fallback to getenv("HOME"); Stepan Kasal
2014-06-04 13:47 ` Duy Nguyen
2014-06-04 14:05 ` Erik Faye-Lund
2014-06-04 14:55 ` Karsten Blees
2014-06-04 15:14 ` Johannes Schindelin
2014-06-04 15:18 ` Erik Faye-Lund
2014-06-04 15:27 ` Johannes Schindelin
2014-06-04 15:45 ` Stepan Kasal
2014-06-04 15:56 ` [msysGit] " Johannes Schindelin
2014-06-04 16:16 ` Stepan Kasal
2014-06-04 17:49 ` [msysGit] " Johannes Schindelin
2014-06-06 9:12 ` Git for Windows SDK Philip Oakley
2014-06-04 23:10 ` Re: [PATCH] Add a Windows-specific fallback to getenv("HOME"); Duy Nguyen
2014-06-06 19:26 ` Sebastian Schuberth
2014-06-04 15:46 ` Johannes Schindelin
2014-06-05 1:42 ` Karsten Blees [this message]
2014-06-05 8:03 ` [PATCH v2] " Stepan Kasal
2014-06-05 8:32 ` [msysGit] " Torsten Bögershausen
2014-06-05 10:23 ` [PATCH v3] " Stepan Kasal
2014-06-05 9:40 ` [PATCH v2] " Karsten Blees
2014-06-05 9:58 ` Erik Faye-Lund
2014-06-05 21:44 ` Karsten Blees
2014-06-06 8:03 ` Stepan Kasal
2014-06-05 11:23 ` Stepan Kasal
2014-06-05 13:39 ` Johannes Schindelin
2014-06-05 20:03 ` Karsten Blees
2014-06-05 12:03 ` Re: [PATCH] " Johannes Schindelin
2014-06-05 12:15 ` [msysGit] " Stepan Kasal
2014-06-05 14:33 ` Karsten Blees
2014-06-04 14:53 ` Stepan Kasal
2014-06-04 15:13 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=538FCAF5.7030102@gmail.com \
--to=karsten.blees@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=kasal@ucw.cz \
--cc=kusmabite@gmail.com \
--cc=msysgit@googlegroups.com \
--cc=pclouds@gmail.com \
--cc=thomas.braun@virtuell-zuhause.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).