@matheusbsbs / matheus-bagliano / commits / 3eb5682b0b
Fork 0

git-gui: use `git --html-path` to get the location of installed HTML 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>

Markus Heidelberg committed Apr 5, 2009 at 03:48 UTC 3eb5682b0b1c16c1b9232f04aff13bd189573b4d
1 file changed +29 -4
git-gui.sh
+29 -4
@@ -122,6 +122,7 @@ unset oguimsg
122 set _appname {Git Gui}
123 set _gitdir {}
124 set _gitexec {}
125 +set _githtmldir {}
126 set _reponame {}
127 set _iscygwin {}
128 set _search_path {}
@@ -168,6 +169,28 @@ proc gitexec {args} {
169 return [eval [list file join $_gitexec] $args]
170 }
171
172 +proc githtmldir {args} {
173 + global _githtmldir
174 + if {$_githtmldir eq {}} {
175 + if {[catch {set _githtmldir [git --html-path]}]} {
176 + # Git not installed or option not yet supported
177 + return {}
178 + }
179 + if {[is_Cygwin]} {
180 + set _githtmldir [exec cygpath \
181 + --windows \
182 + --absolute \
183 + $_githtmldir]
184 + } else {
185 + set _githtmldir [file normalize $_githtmldir]
186 + }
187 + }
188 + if {$args eq {}} {
189 + return $_githtmldir
190 + }
191 + return [eval [list file join $_githtmldir] $args]
192 +}
193 +
194 proc reponame {} {
195 return $::_reponame
196 }
@@ -2591,11 +2614,13 @@ if {![is_MacOSX]} {
2614 }
2615
2616
2594 -set doc_path [file dirname [gitexec]]
2595 -set doc_path [file join $doc_path Documentation index.html]
2617 +set doc_path [githtmldir]
2618 +if {$doc_path ne {}} {
2619 + set doc_path [file join $doc_path index.html]
2620
2597 -if {[is_Cygwin]} {
2598 - set doc_path [exec cygpath --mixed $doc_path]
2621 + if {[is_Cygwin]} {
2622 + set doc_path [exec cygpath --mixed $doc_path]
2623 + }
2624 }
2625
2626 if {[file isfile $doc_path]} {