Skip to content

Commit 3eb5682

Browse files
marcowsspearce
authored andcommitted
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 <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 122ee54 commit 3eb5682

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

git-gui.sh

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ unset oguimsg
122122
set _appname {Git Gui}
123123
set _gitdir {}
124124
set _gitexec {}
125+
set _githtmldir {}
125126
set _reponame {}
126127
set _iscygwin {}
127128
set _search_path {}
@@ -168,6 +169,28 @@ proc gitexec {args} {
168169
return [eval [list file join $_gitexec] $args]
169170
}
170171

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+
171194
proc reponame {} {
172195
return $::_reponame
173196
}
@@ -2591,11 +2614,13 @@ if {![is_MacOSX]} {
25912614
}
25922615
25932616
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]
25962620
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+
}
25992624
}
26002625
26012626
if {[file isfile $doc_path]} {

0 commit comments

Comments
 (0)