@matheusbsbs / matheus-bagliano / commits / 2db21e709a
Fork 0

git-gui: Use git web--browser for web browsing

This patch removes git-gui specific webbrowser guessing and instead relies on git web--browser to do the right thing, removing unnecessary code duplication. New function start_browser encapsulates the browser execution, for usage from other parts of code. This will also make git-gui show the documentation menu item even in cases it might not be able to start up a browser, these cases should be however only very rare. Signed-off-by: Petr Baudis <petr.baudis@novartis.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Petr Baudis committed Sep 24, 2008 at 23:57 UTC 2db21e709a1345d84178e53079e861232c243bd1
1 file changed +7 -23
git-gui.sh
+7 -23
@@ -2493,8 +2493,7 @@ if {![is_MacOSX]} {
2493 -command do_about
2494 }
2495
2496 -set browser {}
2497 -catch {set browser $repo_config(instaweb.browser)}
2496 +
2497 set doc_path [file dirname [gitexec]]
2498 set doc_path [file join $doc_path Documentation index.html]
2499
@@ -2502,34 +2501,19 @@ if {[is_Cygwin]} {
2501 set doc_path [exec cygpath --mixed $doc_path]
2502 }
2503
2505 -if {$browser eq {}} {
2506 - if {[is_MacOSX]} {
2507 - set browser open
2508 - } elseif {[is_Cygwin]} {
2509 - set program_files [file dirname [exec cygpath --windir]]
2510 - set program_files [file join $program_files {Program Files}]
2511 - set firefox [file join $program_files {Mozilla Firefox} firefox.exe]
2512 - set ie [file join $program_files {Internet Explorer} IEXPLORE.EXE]
2513 - if {[file exists $firefox]} {
2514 - set browser $firefox
2515 - } elseif {[file exists $ie]} {
2516 - set browser $ie
2517 - }
2518 - unset program_files firefox ie
2519 - }
2520 -}
2521 -
2504 if {[file isfile $doc_path]} {
2505 set doc_url "file:$doc_path"
2506 } else {
2507 set doc_url {http://www.kernel.org/pub/software/scm/git/docs/}
2508 }
2509
2528 -if {$browser ne {}} {
2529 - .mbar.help add command -label [mc "Online Documentation"] \
2530 - -command [list exec $browser $doc_url &]
2510 +proc start_browser {url} {
2511 + git "web--browse" $url
2512 }
2532 -unset browser doc_path doc_url
2513 +
2514 +.mbar.help add command -label [mc "Online Documentation"] \
2515 + -command [list start_browser $doc_url]
2516 +unset doc_path doc_url
2517
2518 # -- Standard bindings
2519 #