{"thread":{"id":"51429","subject":"[PATCH 0/1] Give Git a HOME on Windows","startedAt":"2019-07-04T09:20:36Z","lastAt":"2019-07-04T09:20:36Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget","Karsten Blees via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"378584","messageId":"pull.218.git.gitgitgadget@gmail.com","threadId":"51429","inReplyTo":null,"subject":"[PATCH 0/1] Give Git a HOME on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-07-04T09:20:32Z","receivedAt":"2019-07-04T09:20:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"The environment variable HOME is a well-known concept on Unix/Linux, but not\nso much on Windows. In fact, there are competing concepts, and they fulfill\nseparate roles.\n\nLet's try to map the closest that we can find to HOME so that Git is happy.\n\nGit for Windows carries this patch since 2015, so I think we're pretty sure\nthat our chosen strategy works.\n\nKarsten Blees (1):\n  mingw: initialize HOME on startup\n\n compat/mingw.c | 24 ++++++++++++++++++++++++\n 1 file changed, 24 insertions(+)\n\n\nbase-commit: aa25c82427ae70aebf3b8f970f2afd54e9a2a8c6\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-218%2Fdscho%2Fmingw-home-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-218/dscho/mingw-home-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/218\n-- \ngitgitgadget\n"},{"id":"378585","messageId":"fd6df1795048ebebc54502ef8d2ddd7728a08085.1562232032.git.gitgitgadget@gmail.com","threadId":"51429","inReplyTo":"pull.218.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] mingw: initialize HOME on startup","fromName":"Karsten Blees via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-07-04T09:20:33Z","receivedAt":"2019-07-04T09:20:36Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nHOME initialization was historically duplicated in many different places,\nincluding /etc/profile, launch scripts such as git-bash.vbs and gitk.cmd,\nand (although slightly broken) in the git-wrapper.\n\nEven unrelated projects such as GitExtensions and TortoiseGit need to\nimplement the same logic to be able to call git directly.\n\nInitialize HOME in git's own startup code so that we can eventually retire\nall the duplicate initialization code.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 24 ++++++++++++++++++++++++\n 1 file changed, 24 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 9b6d2400e1..1047427cb5 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2299,6 +2299,30 @@ static void setup_windows_environment(void)\n \t/* simulate TERM to enable auto-color (see color.c) */\n \tif (!getenv(\"TERM\"))\n \t\tsetenv(\"TERM\", \"cygwin\", 1);\n+\n+\t/* calculate HOME if not set */\n+\tif (!getenv(\"HOME\")) {\n+\t\t/*\n+\t\t * try $HOMEDRIVE$HOMEPATH - the home share may be a network\n+\t\t * location, thus also check if the path exists (i.e. is not\n+\t\t * disconnected)\n+\t\t */\n+\t\tif ((tmp = getenv(\"HOMEDRIVE\"))) {\n+\t\t\tstruct strbuf buf = STRBUF_INIT;\n+\t\t\tstrbuf_addstr(&buf, tmp);\n+\t\t\tif ((tmp = getenv(\"HOMEPATH\"))) {\n+\t\t\t\tstrbuf_addstr(&buf, tmp);\n+\t\t\t\tif (is_directory(buf.buf))\n+\t\t\t\t\tsetenv(\"HOME\", buf.buf, 1);\n+\t\t\t\telse\n+\t\t\t\t\ttmp = NULL; /* use $USERPROFILE */\n+\t\t\t}\n+\t\t\tstrbuf_release(&buf);\n+\t\t}\n+\t\t/* use $USERPROFILE if the home share is not available */\n+\t\tif (!tmp && (tmp = getenv(\"USERPROFILE\")))\n+\t\t\tsetenv(\"HOME\", tmp, 1);\n+\t}\n }\n \n /*\n-- \ngitgitgadget\n"}]}