This patch was inspired by ClearCase command 'ct man', which
Subsystems (2)
PATCH 1/2 This patch was inspired by ClearCase command 'ct man', which
opens an html help file on Windows. I at first attempted to implement it for MinGW port only but found it so useful that I wanted to have it even in Linux.
A new option '--html' is added to git. When git-help is called with --html, it will try to open an html file located at $(docdir)/html using xdg-open. HTML files are not installed by default so users have to install them manually or have their distributors to do that.
There are two new config options introduced in this patch. The first is core.help. It has one of three values: html, auto or man. 'html' has the same effect as git-help --html. 'auto' will in addition fall back to man pages if possible. 'man' is 'I hate html, give me my man pages'. The second option is core.htmlprogram, used to specify the program you want to open html files instead of xdg-open. You can override the default program by appending HTML_PROGRAM=blah when calling make. core.htmlprogram can contain %p, %f or %b. If none is given, %p will be appended.
--- Documentation/config.txt | 16 +++++ Documentation/git.txt | 5 +- Makefile | 5 +- cache.h | 2 + config.c | 17 +++++ config.mak.in | 3 +- environment.c | 2 + git.c | 2 +- help.c | 166 +++++++++++++++++++++++++++++++++++++++++++++- 9 files changed, 212 insertions(+), 6 deletions(-)
Documentation/config.txt +16 -0
@@ -262,6 +262,22 @@ core.excludeFile:: of files which are not meant to be tracked. See gitlink:gitignore[5]. +core.help:: + If 'html', it is equivalent to 'git-help' with option --html. + If 'auto', it tries to open html files first. If that attempt fails + (the html program does not exist or the program return non-zero + value), then it will fall back to man pages. If 'man', always use + man pages as usual. + +core.htmlprogram:: + Specify the program used to open html help files when 'git-help' + is called with option --html or core.help is other than 'man'. + By default, xdg-open will be used. + Special strings '%p', '%f' and '%b' will be replaced with html + full path, file name and git command (without .html suffix) + respectively. If none is given, '%p' will be automatically appended + to the command line. + alias.*:: Command aliases for the gitlink:git[1] command wrapper - e.g. after defining "alias.last = cat-file commit HEAD", the invocation
Documentation/git.txt +4 -1
@@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] - [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS] + [--bare] [--git-dir=GIT_DIR] [--help [--html]] COMMAND [ARGS] DESCRIPTION -----------
@@ -87,6 +87,9 @@ OPTIONS commands. If a git command is named this option will bring up the man-page for that command. If the option '--all' or '-a' is given then all available commands are printed. + If option '--html' is given, try opening html files instead of + using 'man'. The default program to open html files is xdg-open. + See 'git-config' to know how to change html program. --exec-path:: Path to wherever your core git programs are installed.
Makefile +4 -1
@@ -186,6 +186,7 @@ export TCL_PATH TCLTK_PATH # explicitly what architecture to check for. Fix this up for yours.. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ +HTML_PROGRAM=xdg-open ### --- END CONFIGURATION SECTION ---
@@ -693,6 +694,7 @@ ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG)) DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) bindir_SQ = $(subst ','\'',$(bindir)) gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) +html_dir_SQ = $(subst ','\'',$(html_dir)) template_dir_SQ = $(subst ','\'',$(template_dir)) prefix_SQ = $(subst ','\'',$(prefix))
@@ -741,7 +743,8 @@ git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \ $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS) -help.o: common-cmds.h +help.o: help.c common-cmds.h + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DHTML_DIR='"$(html_dir_SQ)"' -DHTML_PROGRAM='"$(HTML_PROGRAM)"' $< git-merge-subtree$X: git-merge-recursive$X $(QUIET_BUILT_IN)rm -f $@ && ln git-merge-recursive$X $@
cache.h +2 -0
@@ -288,6 +288,8 @@ extern size_t packed_git_window_size;extern size_t packed_git_limit;extern size_t delta_base_cache_limit;extern int auto_crlf; +extern int show_html_help; +extern const char *html_help_program;#define GIT_REPO_VERSION 0extern int repository_format_version;
config.c +17 -0
@@ -382,6 +382,23 @@ int git_default_config(const char *var, const char *value)return 0 ; } +if (!strcmp (var,"core.help" )) { +if (!strcmp (value,"auto" )) + show_html_help =2 ; +else if (!strcmp (value,"html" )) + show_html_help =1 ; +else if (!strcmp (value,"man" )) + show_html_help =0 ; +else +return 1 ; +return 0 ; + } + +if (!strcmp (var,"core.htmlprogram" )) { + html_help_program =xstrdup (value); +return 0 ; + } +/* Add other config variables here and to Documentation/config.txt. */ return 0 ; }
config.mak.in +2 -1
@@ -8,12 +8,14 @@ TAR = @TAR@ #INSTALL = @INSTALL@ # needs install-sh or install.sh in sources TCLTK_PATH = @TCLTK_PATH@ +PACKAGE_TARNAME=@PACKAGE_TARNAME@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ #gitexecdir = @libexecdir@/git-core/ datarootdir = @datarootdir@ template_dir = @datadir@/git-core/templates/ +html_dir = @docdir@/html/ mandir=@mandir@
@@ -38,4 +40,3 @@ NO_STRCASESTR=@NO_STRCASESTR@ NO_STRLCPY=@NO_STRLCPY@ NO_SETENV=@NO_SETENV@ NO_ICONV=@NO_ICONV@ -
environment.c +2 -0
@@ -32,6 +32,8 @@ size_t delta_base_cache_limit = 16 * 1024 * 1024;int pager_in_use;int pager_use_color =1 ;int auto_crlf =0 ;/* 1: both ways, -1: only when adding git objects */ +int show_html_help =0 ; +const char *html_help_program =NULL ;static const char *git_dir;static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;
git.c +1 -1
@@ -4,7 +4,7 @@#include "quote.h" const char git_usage_string[] = -"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]" ; +"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help [--html]] COMMAND [ARGS]" ;static void prepend_to_path (const char *dir,int len) {
help.c +164 -2
184 lines not on this page · raw message
Signature · 1 line
1.5.0.7
Quoted 3 lines · Nguyen Thai Ngoc Duy
opens an html help file on Windows. I at first attempted to implement it for MinGW port only but found it so useful that I wanted to have it even in Linux.
Could you _please_ follow git commit message convention, which is first line providing summary of a change, separated by empty line from the rest of commit description.
For example:
-- >8 --
Subject: [PATCH 1/2] Add '--html' option to git, which gives help in HTML
This patch was inspired by ClearCase command 'ct man', which opens an html help file on Windows. I at first attempted to implement it for MinGW port only but found it so useful that I wanted to have it even in Linux.
[...]
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git