Skip to content

Commit 676c495

Browse files
mark987ttaylorr
authored andcommitted
git-gui: cleanup git-bash menu item
git-gui on Git for Windows creates a menu item to start a git-bash session for the current repository. This menu-item works as desired when git-gui is installed in the Git for Windows (g4w) distribution, but not when run from a different location such as normally done in development. The reason is that git-bash's location is known to be '/git-bash' in the Unix pathname space known to MSYS, but this is not known in the Windows pathname space. Instead, git-gui derives a pathname for git-bash assuming it is at a known relative location. If git-gui is run from a different directory than assumed in g4w, the relative location changes, and git-gui resorts to running a generic bash login session in a Windows console. But, the MSYS system underlying Git for Windows includes the 'cygpath' utility to convert between Unix and Windows pathnames. Let's use this so git-bash's Windows pathname is determined directly from /git-bash. Signed-off-by: Mark Levedahl <[email protected]> Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 00c7aa8 commit 676c495

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

git-gui.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,17 +2759,16 @@ if {![is_bare]} {
27592759

27602760
if {[is_Windows]} {
27612761
# Use /git-bash.exe if available
2762-
set normalized [file normalize $::argv0]
2763-
regsub "/mingw../libexec/git-core/git-gui$" \
2764-
$normalized "/git-bash.exe" cmdLine
2765-
if {$cmdLine != $normalized && [file exists $cmdLine]} {
2766-
set cmdLine [list "Git Bash" $cmdLine &]
2762+
set _git_bash [exec cygpath -m /git-bash.exe]
2763+
if {[file executable $_git_bash]} {
2764+
set _bash_cmdline [list "Git Bash" $_git_bash &]
27672765
} else {
2768-
set cmdLine [list "Git Bash" bash --login -l &]
2766+
set _bash_cmdline [list "Git Bash" bash --login -l &]
27692767
}
27702768
.mbar.repository add command \
27712769
-label [mc "Git Bash"] \
2772-
-command {eval exec [list [_which cmd] /c start] $cmdLine}
2770+
-command {eval exec [list [_which cmd] /c start] $_bash_cmdline}
2771+
unset _git_bash
27732772
}
27742773

27752774
if {[is_Windows] || ![is_bare]} {

0 commit comments

Comments
 (0)