Skip to content

Commit

Permalink
git-gui: use git --html-path to get the location of installed HTML …
Browse files Browse the repository at this point in the history
…docs

Previously a hardcoded path $GIT_EXEC_PATH/../Documentation/ was used to
search for the documentation, when the user has asked for it via menu
"Help -> Online Documentation".
This didn't work for the default directory structure.

To find the path reliably, use the new git command line option, which
returns the correct path.

If the output of `git --html-path` is empty because git is not found or
the option is not yet supported in the installed git, the documentation
from kernel.org is launched. There is no additional guessing of the
right location of the installed docs.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Markus Heidelberg authored and Shawn O. Pearce committed Apr 5, 2009
1 parent 122ee54 commit 3eb5682
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ unset oguimsg
set _appname {Git Gui}
set _gitdir {}
set _gitexec {}
set _githtmldir {}
set _reponame {}
set _iscygwin {}
set _search_path {}
Expand Down Expand Up @@ -168,6 +169,28 @@ proc gitexec {args} {
return [eval [list file join $_gitexec] $args]
}

proc githtmldir {args} {
global _githtmldir
if {$_githtmldir eq {}} {
if {[catch {set _githtmldir [git --html-path]}]} {
# Git not installed or option not yet supported
return {}
}
if {[is_Cygwin]} {
set _githtmldir [exec cygpath \
--windows \
--absolute \
$_githtmldir]
} else {
set _githtmldir [file normalize $_githtmldir]
}
}
if {$args eq {}} {
return $_githtmldir
}
return [eval [list file join $_githtmldir] $args]
}

proc reponame {} {
return $::_reponame
}
Expand Down Expand Up @@ -2591,11 +2614,13 @@ if {![is_MacOSX]} {
}
set doc_path [file dirname [gitexec]]
set doc_path [file join $doc_path Documentation index.html]
set doc_path [githtmldir]
if {$doc_path ne {}} {
set doc_path [file join $doc_path index.html]
if {[is_Cygwin]} {
set doc_path [exec cygpath --mixed $doc_path]
if {[is_Cygwin]} {
set doc_path [exec cygpath --mixed $doc_path]
}
}
if {[file isfile $doc_path]} {
Expand Down

0 comments on commit 3eb5682

Please sign in to comment.