{"thread":{"id":"44894","subject":"[BUG/RFC] Git Gui: GIT_DIR leaks to spawned Git Bash","startedAt":"2017-01-16T22:41:58Z","lastAt":"2017-01-18T13:04:44Z","messageCount":4,"participants":["Max Kirillov","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"309503","messageId":"20170116224022.GA8539@jessie.local","threadId":"44894","inReplyTo":null,"subject":"[BUG/RFC] Git Gui: GIT_DIR leaks to spawned Git Bash","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2017-01-16T22:40:22Z","receivedAt":"2017-01-16T22:41:58Z","isPatch":false,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"Hello.\n\nApparently various GIT_* environment variables (most\ninteresting is GIT_DIR but AFAIR there were more) leak to\nshell session launched from Git Gui's \"Git Bash\" menu item.\nWhich can cause unexpected results if user navigates in that\nshell to some other repository (in can also include starting\nanother terminal window etc. to make user forget original\ncontext) and tries to do something there.\n\nI think is would be appropriate to clean up the environment\nwhile starting any program from git gui. It may have\ndownside that the environment could be set intentionally,\nand now is's removed, but (1) there seems to be no way to\ndistinguish intentionally vs automatically set GIT_DIR, and\n(2) the spawned program may be intended to be used\nindependly even if the environment was set intentionally for\ngit gui.\n\nBut I would like to note that I find it wrong for the \"git\"\ndispatcher to set up any enrironment to the spawned\ncommand-specific executable. Because it mixes the concerns\nof that variables - are they user-settable variables to\ntweak the git's behavior, or internal ones to transport the\ndiscovered paths and other info to scripts which cannot do\nthe standard discovery? Not clear. There has been bugs\nrelated to that already, for example [1].\n\n[1] https://public-inbox.org/git/1409784120-2228-1-git-send-email-max@max630.net/\n\n-- \nMax\n"},{"id":"309512","messageId":"alpine.DEB.2.20.1701171145050.3469@virtualbox","threadId":"44894","inReplyTo":"20170116224022.GA8539@jessie.local","subject":"Re: [BUG/RFC] Git Gui: GIT_DIR leaks to spawned Git Bash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-01-17T10:52:29Z","receivedAt":"2017-01-17T10:53:16Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Max,\n\nOn Tue, 17 Jan 2017, Max Kirillov wrote:\n\n> Apparently various GIT_* environment variables (most\n> interesting is GIT_DIR but AFAIR there were more) leak to\n> shell session launched from Git Gui's \"Git Bash\" menu item.\n\nGiven that you call it from Git GUI, i.e. for a *specific* worktree, I do\nnot think that this bug is *all* that critical. After all, you won't even\nnotice unless you use the very same Git Bash to navigate to a *different*\nworktree.\n\nHaving said that, if you have the time and energy to come up with a patch,\nI will definitely try my best to help you get it integrated.\n\nAnd having said *that*, I have to admit that I was unable to reproduce:\nGIT_DIR was set neither when starting Git GUI from the Start Menu (and\nthen navigating to a previously-opened worktree because I am too lazy to\nnavigate manually), nor when starting Git GUI from a Git CMD in a worktree\nvia `git gui`. In both cases, the environment contained only the following\nvariables whose name starts with \"GIT_\": $GIT_ASKPASS, $GIT_ASK_YESNO and\n$GIT_EXEC_PATH.\n\nI tested with Git for Windows v2.11.0(3), the latest offical version.\n\nThanks,\nJohannes\n"},{"id":"309536","messageId":"20170117184224.GA23841@jessie.local","threadId":"44894","inReplyTo":"alpine.DEB.2.20.1701171145050.3469@virtualbox","subject":"Re: [BUG/RFC] Git Gui: GIT_DIR leaks to spawned Git Bash","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2017-01-17T18:42:24Z","receivedAt":"2017-01-17T18:51:30Z","isPatch":false,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"On Tue, Jan 17, 2017 at 11:52:29AM +0100, Johannes Schindelin wrote:\n> Hi Max,\n> \n> On Tue, 17 Jan 2017, Max Kirillov wrote:\n> \n>> Apparently various GIT_* environment variables (most\n>> interesting is GIT_DIR but AFAIR there were more) leak to\n>> shell session launched from Git Gui's \"Git Bash\" menu item.\n\n...\n\n> After all, you won't even notice unless you use the very\n> same Git Bash to navigate to a *different* worktree.\n\nThat's right, I haven't been noticing it myself for quite a\ntime. But once I decided to tweak my habits to having only\none terminal window opened, and immediately noticed.\n\n> And having said *that*, I have to admit that I was unable to reproduce\n\nI have found exact way to reproduce it and actually the\nreason. Turns out to be obvious mistake in code. PR is in\ngithub: https://github.com/git-for-windows/git/pull/1032\n\n-- \nMax\n"},{"id":"309625","messageId":"alpine.DEB.2.20.1701181402210.3469@virtualbox","threadId":"44894","inReplyTo":"20170117184224.GA23841@jessie.local","subject":"Re: [BUG/RFC] Git Gui: GIT_DIR leaks to spawned Git Bash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-01-18T13:04:03Z","receivedAt":"2017-01-18T13:04:44Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Max,\n\nOn Tue, 17 Jan 2017, Max Kirillov wrote:\n\n> On Tue, Jan 17, 2017 at 11:52:29AM +0100, Johannes Schindelin wrote:\n> \n> > And having said *that*, I have to admit that I was unable to reproduce\n> \n> I have found exact way to reproduce it and actually the reason. Turns\n> out to be obvious mistake in code. PR is in github:\n> https://github.com/git-for-windows/git/pull/1032\n\nAs I pointed out in my review, I think that GIT_DIR is actually only set\nfor `gitk` in the non-submodule case. So I guess if I run Git GUI, spawn\ngitk, and then Git Bash, it will have GIT_DIR set.\n\n*clicketyclick*\n\nBingo. That reproduces the problem here.\n\nThanks,\nJohannes\n"}]}