{"thread":{"id":"18725","subject":"[PATCH 0/2] Reliably open the installed HTML docs from git-gui","startedAt":"2009-04-05T01:33:45Z","lastAt":"2009-04-05T02:15:16Z","messageCount":4,"participants":["Markus Heidelberg"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"110365","messageId":"200904050333.46453.markus.heidelberg@web.de","threadId":"18725","inReplyTo":null,"subject":"[PATCH 0/2] Reliably open the installed HTML docs from git-gui","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-05T01:33:45Z","receivedAt":"2009-04-05T01:33:45Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"The path to the installed HTML documentation has to be queried, so that git-gui\nis able to open it for viewing. This doesn't really work currently, because a\nhardcoded path is used.\n\nMarkus Heidelberg (2):\n  add --html-path to get the location of installed HTML docs\n  git-gui: use `git --html-path` to get the location of installed HTML docs\n\n Documentation/git.txt                  |    6 +++++-\n Makefile                               |    1 +\n contrib/completion/git-completion.bash |    1 +\n exec_cmd.c                             |    6 ++++++\n git.c                                  |    5 ++++-\n perl/Git.pm                            |   12 +++++++++++-\n git-gui/git-gui.sh                     |   33 +++++++++++++++++++++++++++++----\n 7 files changed, 57 insertions(+), 7 deletions(-)\n"},{"id":"110366","messageId":"200904050335.43453.markus.heidelberg@web.de","threadId":"18725","inReplyTo":"200904050333.46453.markus.heidelberg@web.de","subject":"[PATCH 1/2] add --html-path to get the location of installed HTML docs","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-05T01:35:43Z","receivedAt":"2009-04-05T01:35:43Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"This can be used in GUIs to open installed HTML documentation in the\nbrowser.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n Documentation/git.txt                  |    6 +++++-\n Makefile                               |    1 +\n contrib/completion/git-completion.bash |    1 +\n exec_cmd.c                             |    6 ++++++\n git.c                                  |    5 ++++-\n perl/Git.pm                            |   12 +++++++++++-\n 6 files changed, 28 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 7513c57..2ce5e6b 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -9,7 +9,7 @@ git - the stupid content tracker\n SYNOPSIS\n --------\n [verse]\n-'git' [--version] [--exec-path[=GIT_EXEC_PATH]]\n+'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]\n     [-p|--paginate|--no-pager]\n     [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]\n     [--help] COMMAND [ARGS]\n@@ -178,6 +178,10 @@ help ...`.\n \tenvironment variable. If no path is given, 'git' will print\n \tthe current setting and then exit.\n \n+--html-path::\n+\tPrint the path to wherever your git HTML documentation is installed\n+\tand exit.\n+\n -p::\n --paginate::\n \tPipe all output into 'less' (or if set, $PAGER).\ndiff --git a/Makefile b/Makefile\nindex 7867eac..28ccad9 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1308,6 +1308,7 @@ git.o git.spec \\\n exec_cmd.o: exec_cmd.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \\\n \t\t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n+\t\t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n \t\t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n \t\t'-DPREFIX=\"$(prefix_SQ)\"' \\\n \t\t$<\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e72ce24..fdc5a24 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1870,6 +1870,7 @@ _git ()\n \t\t\t--bare\n \t\t\t--version\n \t\t\t--exec-path\n+\t\t\t--html-path\n \t\t\t--work-tree=\n \t\t\t--help\n \t\t\t\"\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex 408e4e5..25e0521 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -84,6 +84,12 @@ const char *git_exec_path(void)\n \treturn system_path(GIT_EXEC_PATH);\n }\n \n+/* Returns the location to look for git HTML documentation. */\n+const char *git_html_path(void)\n+{\n+\treturn system_path(GIT_HTML_PATH);\n+}\n+\n static void add_path(struct strbuf *out, const char *path)\n {\n \tif (path && *path) {\ndiff --git a/git.c b/git.c\nindex c2b181e..ff934bd 100644\n--- a/git.c\n+++ b/git.c\n@@ -5,7 +5,7 @@\n #include \"run-command.h\"\n \n const char git_usage_string[] =\n-\t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]\";\n+\t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]\";\n \n const char git_more_info_string[] =\n \t\"See 'git help COMMAND' for more information on a specific command.\";\n@@ -75,6 +75,9 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)\n \t\t\t\tputs(git_exec_path());\n \t\t\t\texit(0);\n \t\t\t}\n+\t\t} else if (!strcmp(cmd, \"--html-path\")) {\n+\t\t\tputs(git_html_path());\n+\t\t\texit(0);\n \t\t} else if (!strcmp(cmd, \"-p\") || !strcmp(cmd, \"--paginate\")) {\n \t\t\tuse_pager = 1;\n \t\t} else if (!strcmp(cmd, \"--no-pager\")) {\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 7d7f2b1..291ff5b 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -56,7 +56,7 @@ require Exporter;\n @EXPORT_OK = qw(command command_oneline command_noisy\n                 command_output_pipe command_input_pipe command_close_pipe\n                 command_bidi_pipe command_close_bidi_pipe\n-                version exec_path hash_object git_cmd_try\n+                version exec_path html_path hash_object git_cmd_try\n                 remote_refs\n                 temp_acquire temp_release temp_reset temp_path);\n \n@@ -492,6 +492,16 @@ C<git --exec-path>). Useful mostly only internally.\n sub exec_path { command_oneline('--exec-path') }\n \n \n+=item html_path ()\n+\n+Return path to the Git html documentation (the same as\n+C<git --html-path>). Useful mostly only internally.\n+\n+=cut\n+\n+sub html_path { command_oneline('--html-path') }\n+\n+\n =item repo_path ()\n \n Return path to the git repository. Must be called on a repository instance.\n-- \n1.6.2.2.428.gea44ab\n"},{"id":"110367","messageId":"200904050348.22103.markus.heidelberg@web.de","threadId":"18725","inReplyTo":"200904050333.46453.markus.heidelberg@web.de","subject":"[PATCH 2/2 resend] git-gui: use `git --html-path` to get the location of installed HTML docs","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-05T01:48:21Z","receivedAt":"2009-04-05T01:48:21Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Previously a hardcoded path $GIT_EXEC_PATH/../Documentation/ was used to\nsearch for the documentation, when the user has asked for it via menu\n\"Help -> Online Documentation\".\nThis didn't work for the default directory structure.\n\nTo find the path reliably, use the new git command line option, which\nreturns the correct path.\n\nIf the output of `git --html-path` is empty because git is not found or\nthe option is not yet supported in the installed git, the documentation\nfrom kernel.org is launched. There is no additional guessing of the\nright location of the installed docs.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n\nResend since the other mail didn't reach the list. This problem happens\nfar too often to me.\n\n git-gui.sh |   33 +++++++++++++++++++++++++++++----\n 1 files changed, 29 insertions(+), 4 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex b3aa732..259251b 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -122,6 +122,7 @@ unset oguimsg\n set _appname {Git Gui}\n set _gitdir {}\n set _gitexec {}\n+set _githtmldir {}\n set _reponame {}\n set _iscygwin {}\n set _search_path {}\n@@ -168,6 +169,28 @@ proc gitexec {args} {\n \treturn [eval [list file join $_gitexec] $args]\n }\n \n+proc githtmldir {args} {\n+\tglobal _githtmldir\n+\tif {$_githtmldir eq {}} {\n+\t\tif {[catch {set _githtmldir [git --html-path]}]} {\n+\t\t\t# Git not installed or option not yet supported\n+\t\t\treturn {}\n+\t\t}\n+\t\tif {[is_Cygwin]} {\n+\t\t\tset _githtmldir [exec cygpath \\\n+\t\t\t\t--windows \\\n+\t\t\t\t--absolute \\\n+\t\t\t\t$_githtmldir]\n+\t\t} else {\n+\t\t\tset _githtmldir [file normalize $_githtmldir]\n+\t\t}\n+\t}\n+\tif {$args eq {}} {\n+\t\treturn $_githtmldir\n+\t}\n+\treturn [eval [list file join $_githtmldir] $args]\n+}\n+\n proc reponame {} {\n \treturn $::_reponame\n }\n@@ -2591,11 +2614,13 @@ if {![is_MacOSX]} {\n }\n \n \n-set doc_path [file dirname [gitexec]]\n-set doc_path [file join $doc_path Documentation index.html]\n+set doc_path [githtmldir]\n+if {$doc_path ne {}} {\n+\tset doc_path [file join $doc_path index.html]\n \n-if {[is_Cygwin]} {\n-\tset doc_path [exec cygpath --mixed $doc_path]\n+\tif {[is_Cygwin]} {\n+\t\tset doc_path [exec cygpath --mixed $doc_path]\n+\t}\n }\n \n if {[file isfile $doc_path]} {\n-- \n1.6.2.2.405.ge9fc3\n"},{"id":"110369","messageId":"200904050415.16672.markus.heidelberg@web.de","threadId":"18725","inReplyTo":"200904050335.43453.markus.heidelberg@web.de","subject":"Re: [PATCH v2 1/2] add --html-path to get the location of installed HTML docs","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-05T02:15:16Z","receivedAt":"2009-04-05T02:15:16Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"This can be used in GUIs to open installed HTML documentation in the\nbrowser.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n\nI've overseen a compiler warning due to a missing prototype. I've\nremoved git_html_path() and call system_path(GIT_HTML_PATH) directly\nnow. This wrapper is not necessary, initially I just followed the way of\nhow --exec-path calls git_exec_path().\n\n Documentation/git.txt                  |    6 +++++-\n Makefile                               |    1 +\n contrib/completion/git-completion.bash |    1 +\n git.c                                  |    5 ++++-\n perl/Git.pm                            |   12 +++++++++++-\n 5 files changed, 22 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 7513c57..2ce5e6b 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -9,7 +9,7 @@ git - the stupid content tracker\n SYNOPSIS\n --------\n [verse]\n-'git' [--version] [--exec-path[=GIT_EXEC_PATH]]\n+'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]\n     [-p|--paginate|--no-pager]\n     [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]\n     [--help] COMMAND [ARGS]\n@@ -178,6 +178,10 @@ help ...`.\n \tenvironment variable. If no path is given, 'git' will print\n \tthe current setting and then exit.\n \n+--html-path::\n+\tPrint the path to wherever your git HTML documentation is installed\n+\tand exit.\n+\n -p::\n --paginate::\n \tPipe all output into 'less' (or if set, $PAGER).\ndiff --git a/Makefile b/Makefile\nindex 7867eac..bcf7cbb 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1191,6 +1191,7 @@ strip: $(PROGRAMS) git$X\n \n git.o: git.c common-cmds.h GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n+\t\t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n \t\t$(ALL_CFLAGS) -c $(filter %.c,$^)\n \n git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e72ce24..fdc5a24 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1870,6 +1870,7 @@ _git ()\n \t\t\t--bare\n \t\t\t--version\n \t\t\t--exec-path\n+\t\t\t--html-path\n \t\t\t--work-tree=\n \t\t\t--help\n \t\t\t\"\ndiff --git a/git.c b/git.c\nindex c2b181e..ff72e22 100644\n--- a/git.c\n+++ b/git.c\n@@ -5,7 +5,7 @@\n #include \"run-command.h\"\n \n const char git_usage_string[] =\n-\t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]\";\n+\t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]\";\n \n const char git_more_info_string[] =\n \t\"See 'git help COMMAND' for more information on a specific command.\";\n@@ -75,6 +75,9 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)\n \t\t\t\tputs(git_exec_path());\n \t\t\t\texit(0);\n \t\t\t}\n+\t\t} else if (!strcmp(cmd, \"--html-path\")) {\n+\t\t\tputs(system_path(GIT_HTML_PATH));\n+\t\t\texit(0);\n \t\t} else if (!strcmp(cmd, \"-p\") || !strcmp(cmd, \"--paginate\")) {\n \t\t\tuse_pager = 1;\n \t\t} else if (!strcmp(cmd, \"--no-pager\")) {\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 7d7f2b1..291ff5b 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -56,7 +56,7 @@ require Exporter;\n @EXPORT_OK = qw(command command_oneline command_noisy\n                 command_output_pipe command_input_pipe command_close_pipe\n                 command_bidi_pipe command_close_bidi_pipe\n-                version exec_path hash_object git_cmd_try\n+                version exec_path html_path hash_object git_cmd_try\n                 remote_refs\n                 temp_acquire temp_release temp_reset temp_path);\n \n@@ -492,6 +492,16 @@ C<git --exec-path>). Useful mostly only internally.\n sub exec_path { command_oneline('--exec-path') }\n \n \n+=item html_path ()\n+\n+Return path to the Git html documentation (the same as\n+C<git --html-path>). Useful mostly only internally.\n+\n+=cut\n+\n+sub html_path { command_oneline('--html-path') }\n+\n+\n =item repo_path ()\n \n Return path to the git repository. Must be called on a repository instance.\n-- \n1.6.2.2.449.g1d936\n"}]}