Skip to content

Commit

Permalink
add --html-path to get the location of installed HTML docs
Browse files Browse the repository at this point in the history
This can be used in GUIs to open installed HTML documentation in the
browser.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Markus Heidelberg authored and Junio C Hamano committed Apr 5, 2009
1 parent e96f368 commit 89a56bf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Documentation/git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ git - the stupid content tracker
SYNOPSIS
--------
[verse]
'git' [--version] [--exec-path[=GIT_EXEC_PATH]]
'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]
Expand Down Expand Up @@ -178,6 +178,10 @@ help ...`.
environment variable. If no path is given, 'git' will print
the current setting and then exit.

--html-path::
Print the path to wherever your git HTML documentation is installed
and exit.

-p::
--paginate::
Pipe all output into 'less' (or if set, $PAGER).
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,7 @@ strip: $(PROGRAMS) git$X

git.o: git.c common-cmds.h GIT-CFLAGS
$(QUIET_CC)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
$(ALL_CFLAGS) -c $(filter %.c,$^)

git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
Expand Down
1 change: 1 addition & 0 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,7 @@ _git ()
--bare
--version
--exec-path
--html-path
--work-tree=
--help
"
Expand Down
5 changes: 4 additions & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "run-command.h"

const char git_usage_string[] =
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
"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]";

const char git_more_info_string[] =
"See 'git help COMMAND' for more information on a specific command.";
Expand Down Expand Up @@ -75,6 +75,9 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
puts(git_exec_path());
exit(0);
}
} else if (!strcmp(cmd, "--html-path")) {
puts(system_path(GIT_HTML_PATH));
exit(0);
} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
use_pager = 1;
} else if (!strcmp(cmd, "--no-pager")) {
Expand Down
12 changes: 11 additions & 1 deletion perl/Git.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require Exporter;
@EXPORT_OK = qw(command command_oneline command_noisy
command_output_pipe command_input_pipe command_close_pipe
command_bidi_pipe command_close_bidi_pipe
version exec_path hash_object git_cmd_try
version exec_path html_path hash_object git_cmd_try
remote_refs
temp_acquire temp_release temp_reset temp_path);

Expand Down Expand Up @@ -492,6 +492,16 @@ C<git --exec-path>). Useful mostly only internally.
sub exec_path { command_oneline('--exec-path') }


=item html_path ()
Return path to the Git html documentation (the same as
C<git --html-path>). Useful mostly only internally.
=cut

sub html_path { command_oneline('--html-path') }


=item repo_path ()
Return path to the git repository. Must be called on a repository instance.
Expand Down

0 comments on commit 89a56bf

Please sign in to comment.