* [PATCH 0/1] git-gui (Windows): use git-bash.exe if it is available @ 2019-09-26 17:46 Johannes Schindelin via GitGitGadget 2019-09-26 17:46 ` [PATCH 1/1] " Thomas Klaeger via GitGitGadget 0 siblings, 1 reply; 7+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2019-09-26 17:46 UTC (permalink / raw) To: git; +Cc: Pratyush Yadav, Johannes Schindelin, Junio C Hamano ... and yet another patch that is carried in Git for Windows for quite a long time. This commit was contributed as https://github.com/patthoyts/git/gui/pull/6 which was ignored for almost three years, and then as https://github.com/prati0100/git-gui/pull/2 which was rejected in favor of a mailing list-centric workflow. The patch is based on Git GUI's master branch at https://github.com/prati0100/git-gui/. Thomas Klaeger (1): git-gui (Windows): use git-bash.exe if it is available git-gui.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) base-commit: 12d29c326551a6570594db525bea42ad9cea8028 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-360%2Fdscho%2Fgit-gui-git-bash-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-360/dscho/git-gui-git-bash-v1 Pull-Request: https://github.com/gitgitgadget/git/pull/360 -- gitgitgadget ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available 2019-09-26 17:46 [PATCH 0/1] git-gui (Windows): use git-bash.exe if it is available Johannes Schindelin via GitGitGadget @ 2019-09-26 17:46 ` Thomas Klaeger via GitGitGadget 2019-09-26 21:57 ` Pratyush Yadav 2019-10-01 13:46 ` Pratyush Yadav 0 siblings, 2 replies; 7+ messages in thread From: Thomas Klaeger via GitGitGadget @ 2019-09-26 17:46 UTC (permalink / raw) To: git; +Cc: Pratyush Yadav, Johannes Schindelin, Junio C Hamano, Thomas Klaeger From: Thomas Klaeger <thklaeger@gmail.com> Git for Windows 2.x ships with an executable that starts the Git Bash with all the environment variables and what not properly set up. It is also adjusted according to the Terminal emulator option chosen when installing Git for Windows (while `bash.exe --login -i` would always launch with Windows' default console). So let's use that executable (usually C:\Program Files\Git\git-bash.exe) instead of `bash.exe --login -i` if its presence was detected. This fixes https://github.com/git-for-windows/git/issues/490 Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- git-gui.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index f9b323abff..5a1bfd736e 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2700,10 +2700,18 @@ if {![is_bare]} { } if {[is_Windows]} { + # Use /git-bash.exe if available + set normalized [file normalize $::argv0] + regsub "/mingw../libexec/git-core/git-gui$" \ + $normalized "/git-bash.exe" cmdLine + if {$cmdLine != $normalized && [file exists $cmdLine]} { + set cmdLine [list "Git Bash" $cmdLine &] + } else { + set cmdLine [list "Git Bash" bash --login -l &] + } .mbar.repository add command \ -label [mc "Git Bash"] \ - -command {eval exec [auto_execok start] \ - [list "Git Bash" bash --login -l &]} + -command {eval exec [auto_execok start] $cmdLine} } if {[is_Windows] || ![is_bare]} { -- gitgitgadget ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available 2019-09-26 17:46 ` [PATCH 1/1] " Thomas Klaeger via GitGitGadget @ 2019-09-26 21:57 ` Pratyush Yadav 2019-09-30 10:27 ` Johannes Schindelin 2019-10-01 13:46 ` Pratyush Yadav 1 sibling, 1 reply; 7+ messages in thread From: Pratyush Yadav @ 2019-09-26 21:57 UTC (permalink / raw) To: Thomas Klaeger via GitGitGadget Cc: git, Johannes Schindelin, Junio C Hamano, Thomas Klaeger On 26/09/19 10:46AM, Thomas Klaeger via GitGitGadget wrote: > From: Thomas Klaeger <thklaeger@gmail.com> > > Git for Windows 2.x ships with an executable that starts the Git Bash > with all the environment variables and what not properly set up. It is > also adjusted according to the Terminal emulator option chosen when > installing Git for Windows (while `bash.exe --login -i` would always > launch with Windows' default console). > > So let's use that executable (usually C:\Program Files\Git\git-bash.exe) > instead of `bash.exe --login -i` if its presence was detected. > > This fixes https://github.com/git-for-windows/git/issues/490 > > Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > --- > git-gui.sh | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/git-gui.sh b/git-gui.sh > index f9b323abff..5a1bfd736e 100755 > --- a/git-gui.sh > +++ b/git-gui.sh > @@ -2700,10 +2700,18 @@ if {![is_bare]} { > } This hunk is kind of hard to understand. I'm writing what I make of it. Please correct me if I read it wrong. Since this is a 4 year old commit not even authored by you, you might not have all the answers. That's OK. But I'd still like to point these things out. I do have a question at the end so please read the entire thing :) > if {[is_Windows]} { > + # Use /git-bash.exe if available > + set normalized [file normalize $::argv0] argv0 would be the location of git-gui. We get an absolute path for the git-gui executable in the variable normalized. > + regsub "/mingw../libexec/git-core/git-gui$" \ > + $normalized "/git-bash.exe" cmdLine This finds the install location of git-bash by doing a string substitution. I'm assuming the path before /mingw.. is the installation directory of git, and so that's where git-bash would reside. We put that directory in cmdLine. Nitpick: most of the code here uses snake case. So s/cmdLine/cmd_line/ > + if {$cmdLine != $normalized && [file exists $cmdLine]} { Why the $cmdLine != $normalized? When would they be equal? The string substitution should always change $cmdLine. > + set cmdLine [list "Git Bash" $cmdLine &] > + } else { > + set cmdLine [list "Git Bash" bash --login -l &] > + } > .mbar.repository add command \ > -label [mc "Git Bash"] \ > - -command {eval exec [auto_execok start] \ > - [list "Git Bash" bash --login -l &]} > + -command {eval exec [auto_execok start] $cmdLine} > } > > if {[is_Windows] || ![is_bare]} { The way of finding the path of git-bash is very hacky and would break as soon as there are any changes in the install locations. Plus, it is not at all easy to understand what's going on at first look. Is there no better way of finding out git-bash's location? Is there something like the PATH environment variable in Windows that we can use to locate git-bash's executable? I have never developed in Windows so I have no idea how things work there. On Linux for example, the exec() family of functions look into the PATH environment variable for the executable, so it is a pretty clean mechanism to execute programs. -- Regards, Pratyush Yadav ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available 2019-09-26 21:57 ` Pratyush Yadav @ 2019-09-30 10:27 ` Johannes Schindelin 2019-10-01 5:28 ` Johannes Sixt 2019-10-01 12:38 ` Pratyush Yadav 0 siblings, 2 replies; 7+ messages in thread From: Johannes Schindelin @ 2019-09-30 10:27 UTC (permalink / raw) To: Pratyush Yadav Cc: Thomas Klaeger via GitGitGadget, git, Junio C Hamano, Thomas Klaeger [-- Attachment #1: Type: text/plain, Size: 3772 bytes --] Hi, On Fri, 27 Sep 2019, Pratyush Yadav wrote: > On 26/09/19 10:46AM, Thomas Klaeger via GitGitGadget wrote: > > From: Thomas Klaeger <thklaeger@gmail.com> > > > > Git for Windows 2.x ships with an executable that starts the Git Bash > > with all the environment variables and what not properly set up. It is > > also adjusted according to the Terminal emulator option chosen when > > installing Git for Windows (while `bash.exe --login -i` would always > > launch with Windows' default console). > > > > So let's use that executable (usually C:\Program Files\Git\git-bash.exe) > > instead of `bash.exe --login -i` if its presence was detected. > > > > This fixes https://github.com/git-for-windows/git/issues/490 > > > > Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > > --- > > git-gui.sh | 12 ++++++++++-- > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/git-gui.sh b/git-gui.sh > > index f9b323abff..5a1bfd736e 100755 > > --- a/git-gui.sh > > +++ b/git-gui.sh > > @@ -2700,10 +2700,18 @@ if {![is_bare]} { > > } > > This hunk is kind of hard to understand. I'm writing what I make of it. > Please correct me if I read it wrong. > > Since this is a 4 year old commit not even authored by you, you might > not have all the answers. That's OK. But I'd still like to point these > things out. I do have a question at the end so please read the entire > thing :) > > > if {[is_Windows]} { > > + # Use /git-bash.exe if available > > + set normalized [file normalize $::argv0] > > argv0 would be the location of git-gui. We get an absolute path for the > git-gui executable in the variable normalized. > > > + regsub "/mingw../libexec/git-core/git-gui$" \ > > + $normalized "/git-bash.exe" cmdLine > > This finds the install location of git-bash by doing a string > substitution. I'm assuming the path before /mingw.. is the installation > directory of git, and so that's where git-bash would reside. We put that > directory in cmdLine. > > Nitpick: most of the code here uses snake case. So s/cmdLine/cmd_line/ > > > + if {$cmdLine != $normalized && [file exists $cmdLine]} { > > Why the $cmdLine != $normalized? When would they be equal? The string > substitution should always change $cmdLine. Except when Git GUI is installed in an unexpected location. This check is purely defensive programming. > > > + set cmdLine [list "Git Bash" $cmdLine &] > > + } else { > > + set cmdLine [list "Git Bash" bash --login -l &] > > + } > > .mbar.repository add command \ > > -label [mc "Git Bash"] \ > > - -command {eval exec [auto_execok start] \ > > - [list "Git Bash" bash --login -l &]} > > + -command {eval exec [auto_execok start] $cmdLine} > > } > > > > if {[is_Windows] || ![is_bare]} { > > The way of finding the path of git-bash is very hacky and would break as > soon as there are any changes in the install locations. Plus, it is not > at all easy to understand what's going on at first look. > > Is there no better way of finding out git-bash's location? Is there > something like the PATH environment variable in Windows that we can use > to locate git-bash's executable? I have never developed in Windows so I > have no idea how things work there. > > On Linux for example, the exec() family of functions look into the PATH > environment variable for the executable, so it is a pretty clean > mechanism to execute programs. That's not an option on Windows. `git-bash.exe` is not intended to be in the `PATH`, specifically not. The implemented method is the best approach we found to determine the location of `git-bash.exe`. Ciao, Johannes ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available 2019-09-30 10:27 ` Johannes Schindelin @ 2019-10-01 5:28 ` Johannes Sixt 2019-10-01 12:38 ` Pratyush Yadav 1 sibling, 0 replies; 7+ messages in thread From: Johannes Sixt @ 2019-10-01 5:28 UTC (permalink / raw) To: Johannes Schindelin Cc: Pratyush Yadav, Thomas Klaeger via GitGitGadget, git, Junio C Hamano, Thomas Klaeger Am 30.09.19 um 12:27 schrieb Johannes Schindelin: > On Fri, 27 Sep 2019, Pratyush Yadav wrote: >>> + if {$cmdLine != $normalized && [file exists $cmdLine]} { >> >> Why the $cmdLine != $normalized? When would they be equal? The string >> substitution should always change $cmdLine. > > Except when Git GUI is installed in an unexpected location. This check > is purely defensive programming. Thanks for being considerate. This case would occur in my setting. -- Hannes ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available 2019-09-30 10:27 ` Johannes Schindelin 2019-10-01 5:28 ` Johannes Sixt @ 2019-10-01 12:38 ` Pratyush Yadav 1 sibling, 0 replies; 7+ messages in thread From: Pratyush Yadav @ 2019-10-01 12:38 UTC (permalink / raw) To: Johannes Schindelin Cc: Thomas Klaeger via GitGitGadget, git, Junio C Hamano, Thomas Klaeger On 30/09/19 12:27PM, Johannes Schindelin wrote: > Hi, > > On Fri, 27 Sep 2019, Pratyush Yadav wrote: > > > On 26/09/19 10:46AM, Thomas Klaeger via GitGitGadget wrote: > > > From: Thomas Klaeger <thklaeger@gmail.com> > > > > > > Git for Windows 2.x ships with an executable that starts the Git Bash > > > with all the environment variables and what not properly set up. It is > > > also adjusted according to the Terminal emulator option chosen when > > > installing Git for Windows (while `bash.exe --login -i` would always > > > launch with Windows' default console). > > > > > > So let's use that executable (usually C:\Program Files\Git\git-bash.exe) > > > instead of `bash.exe --login -i` if its presence was detected. > > > > > > This fixes https://github.com/git-for-windows/git/issues/490 > > > > > > Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch> > > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > > > --- > > > git-gui.sh | 12 ++++++++++-- > > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > > > diff --git a/git-gui.sh b/git-gui.sh > > > index f9b323abff..5a1bfd736e 100755 > > > --- a/git-gui.sh > > > +++ b/git-gui.sh > > > @@ -2700,10 +2700,18 @@ if {![is_bare]} { > > > } > > > > This hunk is kind of hard to understand. I'm writing what I make of it. > > Please correct me if I read it wrong. > > > > Since this is a 4 year old commit not even authored by you, you might > > not have all the answers. That's OK. But I'd still like to point these > > things out. I do have a question at the end so please read the entire > > thing :) > > > > > if {[is_Windows]} { > > > + # Use /git-bash.exe if available > > > + set normalized [file normalize $::argv0] > > > > argv0 would be the location of git-gui. We get an absolute path for the > > git-gui executable in the variable normalized. > > > > > + regsub "/mingw../libexec/git-core/git-gui$" \ > > > + $normalized "/git-bash.exe" cmdLine > > > > This finds the install location of git-bash by doing a string > > substitution. I'm assuming the path before /mingw.. is the installation > > directory of git, and so that's where git-bash would reside. We put that > > directory in cmdLine. > > > > Nitpick: most of the code here uses snake case. So s/cmdLine/cmd_line/ > > > > > + if {$cmdLine != $normalized && [file exists $cmdLine]} { > > > > Why the $cmdLine != $normalized? When would they be equal? The string > > substitution should always change $cmdLine. > > Except when Git GUI is installed in an unexpected location. This check > is purely defensive programming. > > > > > > + set cmdLine [list "Git Bash" $cmdLine &] > > > + } else { > > > + set cmdLine [list "Git Bash" bash --login -l &] > > > + } > > > .mbar.repository add command \ > > > -label [mc "Git Bash"] \ > > > - -command {eval exec [auto_execok start] \ > > > - [list "Git Bash" bash --login -l &]} > > > + -command {eval exec [auto_execok start] $cmdLine} > > > } > > > > > > if {[is_Windows] || ![is_bare]} { > > > > The way of finding the path of git-bash is very hacky and would break as > > soon as there are any changes in the install locations. Plus, it is not > > at all easy to understand what's going on at first look. > > > > Is there no better way of finding out git-bash's location? Is there > > something like the PATH environment variable in Windows that we can use > > to locate git-bash's executable? I have never developed in Windows so I > > have no idea how things work there. > > > > On Linux for example, the exec() family of functions look into the PATH > > environment variable for the executable, so it is a pretty clean > > mechanism to execute programs. > > That's not an option on Windows. `git-bash.exe` is not intended to be in > the `PATH`, specifically not. > > The implemented method is the best approach we found to determine the > location of `git-bash.exe`. Thanks for explaining. Unfortunate that there is no universal way of finding the install location, and we have to rely on educated guesses. Will queue. Thanks. -- Regards, Pratyush Yadav ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] git-gui (Windows): use git-bash.exe if it is available 2019-09-26 17:46 ` [PATCH 1/1] " Thomas Klaeger via GitGitGadget 2019-09-26 21:57 ` Pratyush Yadav @ 2019-10-01 13:46 ` Pratyush Yadav 1 sibling, 0 replies; 7+ messages in thread From: Pratyush Yadav @ 2019-10-01 13:46 UTC (permalink / raw) To: Thomas Klaeger via GitGitGadget Cc: git, Johannes Schindelin, Junio C Hamano, Thomas Klaeger On 26/09/19 10:46AM, Thomas Klaeger via GitGitGadget wrote: > From: Thomas Klaeger <thklaeger@gmail.com> > > Git for Windows 2.x ships with an executable that starts the Git Bash > with all the environment variables and what not properly set up. It is > also adjusted according to the Terminal emulator option chosen when > installing Git for Windows (while `bash.exe --login -i` would always > launch with Windows' default console). > > So let's use that executable (usually C:\Program Files\Git\git-bash.exe) > instead of `bash.exe --login -i` if its presence was detected. > > This fixes https://github.com/git-for-windows/git/issues/490 > > Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch> While applying the patch, my patch check script complained that the author did not sign off. Well, they did... but with a slightly different name (Kläger vs Klaeger) and a completely different email address. I'm not sure if I can do something about it, just thought it was something worth mentioning. -- Regards, Pratyush Yadav ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-10-01 13:47 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-09-26 17:46 [PATCH 0/1] git-gui (Windows): use git-bash.exe if it is available Johannes Schindelin via GitGitGadget 2019-09-26 17:46 ` [PATCH 1/1] " Thomas Klaeger via GitGitGadget 2019-09-26 21:57 ` Pratyush Yadav 2019-09-30 10:27 ` Johannes Schindelin 2019-10-01 5:28 ` Johannes Sixt 2019-10-01 12:38 ` Pratyush Yadav 2019-10-01 13:46 ` Pratyush Yadav
Code repositories for project(s) associated with this public inbox https://80x24.org/mirrors/git.git 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 read-only IMAP folder(s) and NNTP newsgroup(s).