git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2 resend] git-gui: use `git --html-path` to get the location of installed HTML docs

From
Markus Heidelberg <markus.heidelberg@web.de>
Date
Apr 5, 2009, 01:48 UTC
Message-ID
<200904050348.22103.markus.heidelberg@web.de>
In-Reply-To
<200904050333.46453.markus.heidelberg@web.de>

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>
---

Resend since the other mail didn't reach the list. This problem happens far too often to me.

 git-gui.sh |   33 +++++++++++++++++++++++++++++----
 1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index b3aa732..259251b 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -122,6 +122,7 @@ unset oguimsg
 set _appname {Git Gui}
 set _gitdir {}
 set _gitexec {}
+set _githtmldir {}
 set _reponame {}
 set _iscygwin {}
 set _search_path {}
@@ -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
 }
@@ -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]} {
-- 
1.6.2.2.405.ge9fc3
Previous: Markus Heidelberg
Message 4 of 4 in “Reliably open the installed HTML docs from git-gui”
  1. 0/2 Reliably open the installed HTML docs from git-guiMarkus Heidelberg, Apr 5, 2009
  2. 1/2 add --html-path to get the location of installed HTML docsMarkus Heidelberg, Apr 5, 2009
  3. Markus HeidelbergApr 5, 2009
  4. 2/2 git-gui: use `git --html-path` to get the location of installed HTML docsMarkus Heidelberg, Apr 5, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.