{"thread":{"id":"51929","subject":"[PATCH 0/1] git-gui (Windows): use git-bash.exe if it is available","startedAt":"2019-09-26T17:46:22Z","lastAt":"2019-10-01T13:47:05Z","messageCount":7,"participants":["Johannes Schindelin via GitGitGadget","Thomas Klaeger via GitGitGadget","Pratyush Yadav","Johannes Schindelin","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"383005","messageId":"pull.360.git.gitgitgadget@gmail.com","threadId":"51929","inReplyTo":null,"subject":"[PATCH 0/1] git-gui (Windows): use git-bash.exe if it is available","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-26T17:46:18Z","receivedAt":"2019-09-26T17:46:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"... and yet another patch that is carried in Git for Windows for quite a\nlong time.\n\nThis commit was contributed as https://github.com/patthoyts/git/gui/pull/6 \nwhich was ignored for almost three years, and then as \nhttps://github.com/prati0100/git-gui/pull/2 which was rejected in favor of a\nmailing list-centric workflow.\n\nThe patch is based on Git GUI's master branch at \nhttps://github.com/prati0100/git-gui/.\n\nThomas Klaeger (1):\n  git-gui (Windows): use git-bash.exe if it is available\n\n git-gui.sh | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)\n\n\nbase-commit: 12d29c326551a6570594db525bea42ad9cea8028\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-360%2Fdscho%2Fgit-gui-git-bash-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-360/dscho/git-gui-git-bash-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/360\n-- \ngitgitgadget\n"},{"id":"383006","messageId":"414cf2c89876fe122ee18f8d6533f083c2f65654.1569519977.git.gitgitgadget@gmail.com","threadId":"51929","inReplyTo":"pull.360.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available","fromName":"Thomas Klaeger via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-26T17:46:19Z","receivedAt":"2019-09-26T17:46:25Z","isPatch":true,"sender":{"key":"name:Thomas Klaeger","avatar":null},"body":"From: Thomas Klaeger <thklaeger@gmail.com>\n\nGit for Windows 2.x ships with an executable that starts the Git Bash\nwith all the environment variables and what not properly set up. It is\nalso adjusted according to the Terminal emulator option chosen when\ninstalling Git for Windows (while `bash.exe --login -i` would always\nlaunch with Windows' default console).\n\nSo let's use that executable (usually C:\\Program Files\\Git\\git-bash.exe)\ninstead of `bash.exe --login -i` if its presence was detected.\n\nThis fixes https://github.com/git-for-windows/git/issues/490\n\nSigned-off-by: Thomas Kläger <thomas.klaeger@10a.ch>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-gui.sh | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex f9b323abff..5a1bfd736e 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -2700,10 +2700,18 @@ if {![is_bare]} {\n }\n \n if {[is_Windows]} {\n+\t# Use /git-bash.exe if available\n+\tset normalized [file normalize $::argv0]\n+\tregsub \"/mingw../libexec/git-core/git-gui$\" \\\n+\t\t$normalized \"/git-bash.exe\" cmdLine\n+\tif {$cmdLine != $normalized && [file exists $cmdLine]} {\n+\t\tset cmdLine [list \"Git Bash\" $cmdLine &]\n+\t} else {\n+\t\tset cmdLine [list \"Git Bash\" bash --login -l &]\n+\t}\n \t.mbar.repository add command \\\n \t\t-label [mc \"Git Bash\"] \\\n-\t\t-command {eval exec [auto_execok start] \\\n-\t\t\t\t\t  [list \"Git Bash\" bash --login -l &]}\n+\t\t-command {eval exec [auto_execok start] $cmdLine}\n }\n \n if {[is_Windows] || ![is_bare]} {\n-- \ngitgitgadget\n"},{"id":"383041","messageId":"20190926215737.aq4z2vhfrl6j634r@yadavpratyush.com","threadId":"51929","inReplyTo":"414cf2c89876fe122ee18f8d6533f083c2f65654.1569519977.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-09-26T21:57:37Z","receivedAt":"2019-09-26T21:57:43Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 26/09/19 10:46AM, Thomas Klaeger via GitGitGadget wrote:\n> From: Thomas Klaeger <thklaeger@gmail.com>\n> \n> Git for Windows 2.x ships with an executable that starts the Git Bash\n> with all the environment variables and what not properly set up. It is\n> also adjusted according to the Terminal emulator option chosen when\n> installing Git for Windows (while `bash.exe --login -i` would always\n> launch with Windows' default console).\n> \n> So let's use that executable (usually C:\\Program Files\\Git\\git-bash.exe)\n> instead of `bash.exe --login -i` if its presence was detected.\n> \n> This fixes https://github.com/git-for-windows/git/issues/490\n> \n> Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  git-gui.sh | 12 ++++++++++--\n>  1 file changed, 10 insertions(+), 2 deletions(-)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index f9b323abff..5a1bfd736e 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -2700,10 +2700,18 @@ if {![is_bare]} {\n>  }\n  \nThis hunk is kind of hard to understand. I'm writing what I make of it. \nPlease correct me if I read it wrong.\n\nSince this is a 4 year old commit not even authored by you, you might \nnot have all the answers. That's OK. But I'd still like to point these \nthings out. I do have a question at the end so please read the entire \nthing :)\n\n>  if {[is_Windows]} {\n> +\t# Use /git-bash.exe if available\n> +\tset normalized [file normalize $::argv0]\n\nargv0 would be the location of git-gui. We get an absolute path for the \ngit-gui executable in the variable normalized.\n\n> +\tregsub \"/mingw../libexec/git-core/git-gui$\" \\\n> +\t\t$normalized \"/git-bash.exe\" cmdLine\n\nThis finds the install location of git-bash by doing a string \nsubstitution. I'm assuming the path before /mingw.. is the installation \ndirectory of git, and so that's where git-bash would reside. We put that \ndirectory in cmdLine.\n\nNitpick: most of the code here uses snake case. So s/cmdLine/cmd_line/\n\n> +\tif {$cmdLine != $normalized && [file exists $cmdLine]} {\n\nWhy the $cmdLine != $normalized? When would they be equal? The string \nsubstitution should always change $cmdLine.\n\n> +\t\tset cmdLine [list \"Git Bash\" $cmdLine &]\n> +\t} else {\n> +\t\tset cmdLine [list \"Git Bash\" bash --login -l &]\n> +\t}\n>  \t.mbar.repository add command \\\n>  \t\t-label [mc \"Git Bash\"] \\\n> -\t\t-command {eval exec [auto_execok start] \\\n> -\t\t\t\t\t  [list \"Git Bash\" bash --login -l &]}\n> +\t\t-command {eval exec [auto_execok start] $cmdLine}\n>  }\n>  \n>  if {[is_Windows] || ![is_bare]} {\n\nThe way of finding the path of git-bash is very hacky and would break as \nsoon as there are any changes in the install locations. Plus, it is not \nat all easy to understand what's going on at first look.\n\nIs there no better way of finding out git-bash's location? Is there \nsomething like the PATH environment variable in Windows that we can use \nto locate git-bash's executable? I have never developed in Windows so I \nhave no idea how things work there.\n\nOn Linux for example, the exec() family of functions look into the PATH \nenvironment variable for the executable, so it is a pretty clean \nmechanism to execute programs.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383153","messageId":"nycvar.QRO.7.76.6.1909301225300.46@tvgsbejvaqbjf.bet","threadId":"51929","inReplyTo":"20190926215737.aq4z2vhfrl6j634r@yadavpratyush.com","subject":"Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-09-30T10:27:08Z","receivedAt":"2019-09-30T10:27:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 27 Sep 2019, Pratyush Yadav wrote:\n\n> On 26/09/19 10:46AM, Thomas Klaeger via GitGitGadget wrote:\n> > From: Thomas Klaeger <thklaeger@gmail.com>\n> >\n> > Git for Windows 2.x ships with an executable that starts the Git Bash\n> > with all the environment variables and what not properly set up. It is\n> > also adjusted according to the Terminal emulator option chosen when\n> > installing Git for Windows (while `bash.exe --login -i` would always\n> > launch with Windows' default console).\n> >\n> > So let's use that executable (usually C:\\Program Files\\Git\\git-bash.exe)\n> > instead of `bash.exe --login -i` if its presence was detected.\n> >\n> > This fixes https://github.com/git-for-windows/git/issues/490\n> >\n> > Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch>\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> >  git-gui.sh | 12 ++++++++++--\n> >  1 file changed, 10 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/git-gui.sh b/git-gui.sh\n> > index f9b323abff..5a1bfd736e 100755\n> > --- a/git-gui.sh\n> > +++ b/git-gui.sh\n> > @@ -2700,10 +2700,18 @@ if {![is_bare]} {\n> >  }\n>\n> This hunk is kind of hard to understand. I'm writing what I make of it.\n> Please correct me if I read it wrong.\n>\n> Since this is a 4 year old commit not even authored by you, you might\n> not have all the answers. That's OK. But I'd still like to point these\n> things out. I do have a question at the end so please read the entire\n> thing :)\n>\n> >  if {[is_Windows]} {\n> > +\t# Use /git-bash.exe if available\n> > +\tset normalized [file normalize $::argv0]\n>\n> argv0 would be the location of git-gui. We get an absolute path for the\n> git-gui executable in the variable normalized.\n>\n> > +\tregsub \"/mingw../libexec/git-core/git-gui$\" \\\n> > +\t\t$normalized \"/git-bash.exe\" cmdLine\n>\n> This finds the install location of git-bash by doing a string\n> substitution. I'm assuming the path before /mingw.. is the installation\n> directory of git, and so that's where git-bash would reside. We put that\n> directory in cmdLine.\n>\n> Nitpick: most of the code here uses snake case. So s/cmdLine/cmd_line/\n>\n> > +\tif {$cmdLine != $normalized && [file exists $cmdLine]} {\n>\n> Why the $cmdLine != $normalized? When would they be equal? The string\n> substitution should always change $cmdLine.\n\nExcept when Git GUI is installed in an unexpected location. This check\nis purely defensive programming.\n\n>\n> > +\t\tset cmdLine [list \"Git Bash\" $cmdLine &]\n> > +\t} else {\n> > +\t\tset cmdLine [list \"Git Bash\" bash --login -l &]\n> > +\t}\n> >  \t.mbar.repository add command \\\n> >  \t\t-label [mc \"Git Bash\"] \\\n> > -\t\t-command {eval exec [auto_execok start] \\\n> > -\t\t\t\t\t  [list \"Git Bash\" bash --login -l &]}\n> > +\t\t-command {eval exec [auto_execok start] $cmdLine}\n> >  }\n> >\n> >  if {[is_Windows] || ![is_bare]} {\n>\n> The way of finding the path of git-bash is very hacky and would break as\n> soon as there are any changes in the install locations. Plus, it is not\n> at all easy to understand what's going on at first look.\n>\n> Is there no better way of finding out git-bash's location? Is there\n> something like the PATH environment variable in Windows that we can use\n> to locate git-bash's executable? I have never developed in Windows so I\n> have no idea how things work there.\n>\n> On Linux for example, the exec() family of functions look into the PATH\n> environment variable for the executable, so it is a pretty clean\n> mechanism to execute programs.\n\nThat's not an option on Windows. `git-bash.exe` is not intended to be in\nthe `PATH`, specifically not.\n\nThe implemented method is the best approach we found to determine the\nlocation of `git-bash.exe`.\n\nCiao,\nJohannes\n"},{"id":"383191","messageId":"1486440c-b6aa-51d9-c706-b7e531f4d6d0@kdbg.org","threadId":"51929","inReplyTo":"nycvar.QRO.7.76.6.1909301225300.46@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-10-01T05:28:30Z","receivedAt":"2019-10-01T05:28:36Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 30.09.19 um 12:27 schrieb Johannes Schindelin:\n> On Fri, 27 Sep 2019, Pratyush Yadav wrote:\n>>> +\tif {$cmdLine != $normalized && [file exists $cmdLine]} {\n>>\n>> Why the $cmdLine != $normalized? When would they be equal? The string\n>> substitution should always change $cmdLine.\n> \n> Except when Git GUI is installed in an unexpected location. This check\n> is purely defensive programming.\n\nThanks for being considerate. This case would occur in my setting.\n\n-- Hannes\n"},{"id":"383202","messageId":"20191001123843.r6mduhlwpu6xu5us@yadavpratyush.com","threadId":"51929","inReplyTo":"nycvar.QRO.7.76.6.1909301225300.46@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-10-01T12:38:43Z","receivedAt":"2019-10-01T12:38:50Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 30/09/19 12:27PM, Johannes Schindelin wrote:\n> Hi,\n> \n> On Fri, 27 Sep 2019, Pratyush Yadav wrote:\n> \n> > On 26/09/19 10:46AM, Thomas Klaeger via GitGitGadget wrote:\n> > > From: Thomas Klaeger <thklaeger@gmail.com>\n> > >\n> > > Git for Windows 2.x ships with an executable that starts the Git Bash\n> > > with all the environment variables and what not properly set up. It is\n> > > also adjusted according to the Terminal emulator option chosen when\n> > > installing Git for Windows (while `bash.exe --login -i` would always\n> > > launch with Windows' default console).\n> > >\n> > > So let's use that executable (usually C:\\Program Files\\Git\\git-bash.exe)\n> > > instead of `bash.exe --login -i` if its presence was detected.\n> > >\n> > > This fixes https://github.com/git-for-windows/git/issues/490\n> > >\n> > > Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch>\n> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > > ---\n> > >  git-gui.sh | 12 ++++++++++--\n> > >  1 file changed, 10 insertions(+), 2 deletions(-)\n> > >\n> > > diff --git a/git-gui.sh b/git-gui.sh\n> > > index f9b323abff..5a1bfd736e 100755\n> > > --- a/git-gui.sh\n> > > +++ b/git-gui.sh\n> > > @@ -2700,10 +2700,18 @@ if {![is_bare]} {\n> > >  }\n> >\n> > This hunk is kind of hard to understand. I'm writing what I make of it.\n> > Please correct me if I read it wrong.\n> >\n> > Since this is a 4 year old commit not even authored by you, you might\n> > not have all the answers. That's OK. But I'd still like to point these\n> > things out. I do have a question at the end so please read the entire\n> > thing :)\n> >\n> > >  if {[is_Windows]} {\n> > > +\t# Use /git-bash.exe if available\n> > > +\tset normalized [file normalize $::argv0]\n> >\n> > argv0 would be the location of git-gui. We get an absolute path for the\n> > git-gui executable in the variable normalized.\n> >\n> > > +\tregsub \"/mingw../libexec/git-core/git-gui$\" \\\n> > > +\t\t$normalized \"/git-bash.exe\" cmdLine\n> >\n> > This finds the install location of git-bash by doing a string\n> > substitution. I'm assuming the path before /mingw.. is the installation\n> > directory of git, and so that's where git-bash would reside. We put that\n> > directory in cmdLine.\n> >\n> > Nitpick: most of the code here uses snake case. So s/cmdLine/cmd_line/\n> >\n> > > +\tif {$cmdLine != $normalized && [file exists $cmdLine]} {\n> >\n> > Why the $cmdLine != $normalized? When would they be equal? The string\n> > substitution should always change $cmdLine.\n> \n> Except when Git GUI is installed in an unexpected location. This check\n> is purely defensive programming.\n> \n> >\n> > > +\t\tset cmdLine [list \"Git Bash\" $cmdLine &]\n> > > +\t} else {\n> > > +\t\tset cmdLine [list \"Git Bash\" bash --login -l &]\n> > > +\t}\n> > >  \t.mbar.repository add command \\\n> > >  \t\t-label [mc \"Git Bash\"] \\\n> > > -\t\t-command {eval exec [auto_execok start] \\\n> > > -\t\t\t\t\t  [list \"Git Bash\" bash --login -l &]}\n> > > +\t\t-command {eval exec [auto_execok start] $cmdLine}\n> > >  }\n> > >\n> > >  if {[is_Windows] || ![is_bare]} {\n> >\n> > The way of finding the path of git-bash is very hacky and would break as\n> > soon as there are any changes in the install locations. Plus, it is not\n> > at all easy to understand what's going on at first look.\n> >\n> > Is there no better way of finding out git-bash's location? Is there\n> > something like the PATH environment variable in Windows that we can use\n> > to locate git-bash's executable? I have never developed in Windows so I\n> > have no idea how things work there.\n> >\n> > On Linux for example, the exec() family of functions look into the PATH\n> > environment variable for the executable, so it is a pretty clean\n> > mechanism to execute programs.\n> \n> That's not an option on Windows. `git-bash.exe` is not intended to be in\n> the `PATH`, specifically not.\n> \n> The implemented method is the best approach we found to determine the\n> location of `git-bash.exe`.\n\nThanks for explaining. Unfortunate that there is no universal way of \nfinding the install location, and we have to rely on educated guesses.\n\nWill queue. Thanks.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383207","messageId":"20191001134654.vpiygrpczegynfis@yadavpratyush.com","threadId":"51929","inReplyTo":"414cf2c89876fe122ee18f8d6533f083c2f65654.1569519977.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-10-01T13:46:54Z","receivedAt":"2019-10-01T13:47:05Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 26/09/19 10:46AM, Thomas Klaeger via GitGitGadget wrote:\n> From: Thomas Klaeger <thklaeger@gmail.com>\n> \n> Git for Windows 2.x ships with an executable that starts the Git Bash\n> with all the environment variables and what not properly set up. It is\n> also adjusted according to the Terminal emulator option chosen when\n> installing Git for Windows (while `bash.exe --login -i` would always\n> launch with Windows' default console).\n> \n> So let's use that executable (usually C:\\Program Files\\Git\\git-bash.exe)\n> instead of `bash.exe --login -i` if its presence was detected.\n> \n> This fixes https://github.com/git-for-windows/git/issues/490\n> \n> Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch>\n\nWhile applying the patch, my patch check script complained that the \nauthor did not sign off.\n\nWell, they did... but with a slightly different name (Kläger vs  \nKlaeger) and a completely different email address.\n\nI'm not sure if I can do something about it, just thought it was \nsomething worth mentioning.\n\n-- \nRegards,\nPratyush Yadav\n"}]}