From: Junio C Hamano Date: Mon, 10 Dec 2007 09:22:42 +0000 (-0800) Subject: Merge branch 'master' into cc/help X-Git-Tag: v1.5.4-rc0~1^2~8 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7be2b6e02b4f2a1b4812764f65b12cafb11a934e?hp=-c Merge branch 'master' into cc/help This is to primarily pull in MANPATH tweak and help.txt formatting fix from the master branch. --- 7be2b6e02b4f2a1b4812764f65b12cafb11a934e diff --combined Documentation/Makefile index f0df0b0d28,1b5802456d..9f0f9d70f6 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@@ -29,7 -29,6 +29,7 @@@ DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TX prefix?=$(HOME) bindir?=$(prefix)/bin +htmldir?=$(prefix)/share/doc/git-doc mandir?=$(prefix)/share/man man1dir=$(mandir)/man1 man5dir=$(mandir)/man5 @@@ -46,6 -45,9 +46,9 @@@ infodir?=$(prefix)/share/inf MAKEINFO=makeinfo INSTALL_INFO=install-info DOCBOOK2X_TEXI=docbook2x-texi + ifndef PERL_PATH + PERL_PATH = /usr/bin/perl + endif -include ../config.mak.autogen -include ../config.mak @@@ -80,25 -82,22 +83,25 @@@ man7: $(DOC_MAN7 info: git.info install: man - $(INSTALL) -d -m755 $(DESTDIR)$(man1dir) - $(INSTALL) -d -m755 $(DESTDIR)$(man5dir) - $(INSTALL) -d -m755 $(DESTDIR)$(man7dir) - $(INSTALL) -m644 $(DOC_MAN1) $(DESTDIR)$(man1dir) - $(INSTALL) -m644 $(DOC_MAN5) $(DESTDIR)$(man5dir) - $(INSTALL) -m644 $(DOC_MAN7) $(DESTDIR)$(man7dir) + $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir) + $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir) + $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir) + $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir) + $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir) + $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir) install-info: info - $(INSTALL) -d -m755 $(DESTDIR)$(infodir) - $(INSTALL) -m644 git.info $(DESTDIR)$(infodir) + $(INSTALL) -d -m 755 $(DESTDIR)$(infodir) + $(INSTALL) -m 644 git.info $(DESTDIR)$(infodir) if test -r $(DESTDIR)$(infodir)/dir; then \ $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\ else \ echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \ fi +install-html: html + sh ./install-webdoc.sh $(DESTDIR)$(htmldir) + ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE $(MAKE) -C ../ GIT-VERSION-FILE @@@ -109,7 -108,7 +112,7 @@@ # doc.dep : $(wildcard *.txt) build-docdep.perl $(RM) $@+ $@ - perl ./build-docdep.perl >$@+ + $(PERL_PATH) ./build-docdep.perl >$@+ mv $@+ $@ -include doc.dep @@@ -128,7 -127,7 +131,7 @@@ $(cmds_txt): cmd-list.mad cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT) $(RM) $@ - perl ./cmd-list.perl ../command-list.txt + $(PERL_PATH) ./cmd-list.perl ../command-list.txt date >$@ git.7 git.html: git.txt @@@ -165,7 -164,7 +168,7 @@@ user-manual.html: user-manual.xm git.info: user-manual.xml $(RM) $@ $*.texi $*.texi+ $(DOCBOOK2X_TEXI) user-manual.xml --to-stdout >$*.texi+ - perl fix-texi.perl <$*.texi+ >$*.texi + $(PERL_PATH) fix-texi.perl <$*.texi+ >$*.texi $(MAKEINFO) --no-split $*.texi $(RM) $*.texi $*.texi+ diff --combined Documentation/git-help.txt index 0e873fde28,7ddbf467df..ac9e15d774 --- a/Documentation/git-help.txt +++ b/Documentation/git-help.txt @@@ -1,5 -1,5 +1,5 @@@ git-help(1) - ====== + =========== NAME ---- @@@ -7,7 -7,7 +7,7 @@@ git-help - display help information abo SYNOPSIS -------- -'git help' [-a|--all] [COMMAND] +'git help' [-a|--all|-i|--info|-w|--web] [COMMAND] DESCRIPTION ----------- @@@ -20,8 -20,7 +20,8 @@@ If the option '--all' or '-a' is given printed on the standard output. If a git command is named, a manual page for that command is brought -up. The 'man' program is used by default for this purpose. +up. The 'man' program is used by default for this purpose, but this +can be overriden by other options. Note that 'git --help ...' is identical as 'git help ...' because the former is internally converted into the latter. @@@ -29,31 -28,10 +29,31 @@@ OPTIONS ------- -a|--all:: - Prints all the available commands on the standard output. This option superseeds any other option. +-i|--info:: + Use the 'info' program to display the manual page, instead of + the 'man' program that is used by default. + +-w|--web:: + Use a web browser to display the HTML manual page, instead of + the 'man' program that is used by default. ++ +The web browser can be specified using the configuration variable +'help.browser', or 'web.browser' if the former is not set. If none of +these config variables is set, the 'git-browse-help' script (called by +'git-help') will pick a suitable default. ++ +You can explicitly provide a full path to your prefered browser by +setting the configuration variable 'browser..path'. For example, +you can configure the absolute path to firefox by setting +'browser.firefox.path'. Otherwise, 'git-browse-help' assumes the tool +is available in PATH. ++ +Note that the script tries, as much as possible, to display the HTML +page in a new tab on an already opened browser. + Author ------ Written by Junio C Hamano and the git-list diff --combined Documentation/git.txt index c4e4d24ea4,1574ecd77e..a29b634e7a --- a/Documentation/git.txt +++ b/Documentation/git.txt @@@ -104,11 -104,6 +104,11 @@@ OPTION commands. If the option '--all' or '-a' is given then all available commands are printed. If a git command is named this option will bring up the manual page for that command. ++ +Other options are available to control how the manual page is +displayed. See gitlink:git-help[1] for more information, +because 'git --help ...' is converted internally into 'git +help ...'. --exec-path:: Path to wherever your core git programs are installed. @@@ -541,7 -536,7 +541,7 @@@ Author ------- * git's founding father is Linus Torvalds . * The current git nurse is Junio C Hamano . - * The git potty was written by Andres Ericsson . + * The git potty was written by Andreas Ericsson . * General upbringing is handled by the git-list . Documentation diff --combined Makefile index 932b0d4346,4cdb84ba62..429bc1ddb5 --- a/Makefile +++ b/Makefile @@@ -154,10 -154,10 +154,11 @@@ STRIP ?= stri prefix = $(HOME) bindir = $(prefix)/bin + mandir = $(prefix)/share/man gitexecdir = $(bindir) sharedir = $(prefix)/share template_dir = $(sharedir)/git-core/templates +htmldir=$(sharedir)/doc/git-doc ifeq ($(prefix),/usr) sysconfdir = /etc else @@@ -184,7 -184,7 +185,7 @@@ GITWEB_FAVICON = git-favicon.pn GITWEB_SITE_HEADER = GITWEB_SITE_FOOTER = -export prefix bindir gitexecdir sharedir template_dir sysconfdir +export prefix bindir gitexecdir sharedir template_dir htmldir sysconfdir CC = gcc AR = ar @@@ -214,7 -214,7 +215,7 @@@ BASIC_LDFLAGS SCRIPT_SH = \ git-bisect.sh git-checkout.sh \ - git-clone.sh git-commit.sh \ + git-clone.sh \ git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \ git-pull.sh git-rebase.sh git-rebase--interactive.sh \ git-repack.sh git-request-pull.sh \ @@@ -224,8 -224,7 +225,8 @@@ git-merge-resolve.sh \ git-lost-found.sh git-quiltimport.sh git-submodule.sh \ git-filter-branch.sh \ - git-stash.sh + git-stash.sh \ + git-browse-help.sh SCRIPT_PERL = \ git-add--interactive.perl \ @@@ -235,7 -234,7 +236,7 @@@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ - git-status git-instaweb + git-instaweb # ... and all the rest that could be moved out of bindir to gitexecdir PROGRAMS = \ @@@ -261,7 -260,7 +262,7 @@@ EXTRA_PROGRAMS BUILT_INS = \ git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \ git-get-tar-commit-id$X git-init$X git-repo-config$X \ - git-fsck-objects$X git-cherry-pick$X git-peek-remote$X \ + git-fsck-objects$X git-cherry-pick$X git-peek-remote$X git-status$X \ $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS)) # what 'all' will build and 'install' will install, in gitexecdir @@@ -314,7 -313,7 +315,7 @@@ LIB_OBJS = alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \ color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \ convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \ - transport.o bundle.o walker.o parse-options.o + transport.o bundle.o walker.o parse-options.o ws.o BUILTIN_OBJS = \ builtin-add.o \ @@@ -329,6 -328,7 +330,7 @@@ builtin-checkout-index.o \ builtin-check-ref-format.o \ builtin-clean.o \ + builtin-commit.o \ builtin-commit-tree.o \ builtin-count-objects.o \ builtin-describe.o \ @@@ -371,7 -371,6 +373,6 @@@ builtin-rev-parse.o \ builtin-revert.o \ builtin-rm.o \ - builtin-runstatus.o \ builtin-shortlog.o \ builtin-show-branch.o \ builtin-stripspace.o \ @@@ -408,7 -407,9 +409,9 @@@ endi ifeq ($(uname_S),Darwin) NEEDS_SSL_WITH_CRYPTO = YesPlease NEEDS_LIBICONV = YesPlease - OLD_ICONV = UnfortunatelyYes + ifneq ($(shell expr "$(uname_R)" : '9\.'),2) + OLD_ICONV = UnfortunatelyYes + endif NO_STRLCPY = YesPlease NO_MEMMEM = YesPlease endif @@@ -446,6 -447,7 +449,7 @@@ ifeq ($(uname_O),Cygwin NEEDS_LIBICONV = YesPlease NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes NO_TRUSTABLE_FILEMODE = UnfortunatelyYes + OLD_ICONV = UnfortunatelyYes # There are conflicting reports about this. # On some boxes NO_MMAP is needed, and not so elsewhere. # Try commenting this out if you suspect MMAP is more efficient @@@ -745,9 -747,9 +749,10 @@@ ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) bindir_SQ = $(subst ','\'',$(bindir)) + mandir_SQ = $(subst ','\'',$(mandir)) gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) template_dir_SQ = $(subst ','\'',$(template_dir)) +htmldir_SQ = $(subst ','\'',$(htmldir)) prefix_SQ = $(subst ','\'',$(prefix)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) @@@ -792,7 -794,8 +797,8 @@@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \ $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS) - help.o: common-cmds.h + help.o: help.c common-cmds.h GIT-CFLAGS + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_MAN_PATH="$(mandir_SQ)"' $< git-merge-subtree$X: git-merge-recursive$X $(QUIET_BUILT_IN)$(RM) $@ && ln git-merge-recursive$X $@ @@@ -811,7 -814,6 +817,7 @@@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : % -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ + -e 's|@@HTMLDIR@@|$(htmldir_SQ)|g' \ $@.sh >$@+ && \ chmod +x $@+ && \ mv $@+ $@ @@@ -837,9 -839,6 +843,6 @@@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % chmod +x $@+ && \ mv $@+ $@ - git-status: git-commit - $(QUIET_GEN)cp $< $@+ && mv $@+ $@ - gitweb/gitweb.cgi: gitweb/gitweb.perl $(QUIET_GEN)$(RM) $@ $@+ && \ sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \ @@@ -1021,8 -1020,8 +1024,8 @@@ remove-dashes ### Installation rules install: all - $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)' - $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)' + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)' $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install diff --combined help.c index ec0d0155ac,f935887d34..56477f4506 --- a/help.c +++ b/help.c @@@ -239,40 -239,46 +239,62 @@@ void list_common_cmds_help(void } } +static const char *cmd_to_page(const char *git_cmd) +{ + if (!git_cmd) + return "git"; + else if (!prefixcmp(git_cmd, "git")) + return git_cmd; + else { + int page_len = strlen(git_cmd) + 4; + char *p = xmalloc(page_len + 1); + strcpy(p, "git-"); + strcpy(p + 4, git_cmd); + p[page_len] = 0; + return p; + } +} + + static void setup_man_path(void) + { + struct strbuf new_path; + const char *old_path = getenv("MANPATH"); + + strbuf_init(&new_path, 0); + + /* We should always put ':' after our path. If there is no + * old_path, the ':' at the end will let 'man' to try + * system-wide paths after ours to find the manual page. If + * there is old_path, we need ':' as delimiter. */ + strbuf_addstr(&new_path, GIT_MAN_PATH); + strbuf_addch(&new_path, ':'); + if (old_path) + strbuf_addstr(&new_path, old_path); + + setenv("MANPATH", new_path.buf, 1); + + strbuf_release(&new_path); + } + static void show_man_page(const char *git_cmd) { - const char *page; - - if (!prefixcmp(git_cmd, "git")) - page = git_cmd; - else { - int page_len = strlen(git_cmd) + 4; - char *p = xmalloc(page_len + 1); - strcpy(p, "git-"); - strcpy(p + 4, git_cmd); - p[page_len] = 0; - page = p; - } - + const char *page = cmd_to_page(git_cmd); + setup_man_path(); execlp("man", "man", page, NULL); } +static void show_info_page(const char *git_cmd) +{ + const char *page = cmd_to_page(git_cmd); + execlp("info", "info", page, NULL); +} + +static void show_html_page(const char *git_cmd) +{ + const char *page = cmd_to_page(git_cmd); + execl_git_cmd("browse-help", page, NULL); +} + void help_unknown_cmd(const char *cmd) { fprintf(stderr, "git: '%s' is not a git-command. See 'git --help'.\n", cmd); @@@ -287,25 -293,18 +309,25 @@@ int cmd_version(int argc, const char ** int cmd_help(int argc, const char **argv, const char *prefix) { - const char *help_cmd = argc > 1 ? argv[1] : NULL; + const char *help_cmd = argv[1]; - if (!help_cmd) { + if (argc < 2) { printf("usage: %s\n\n", git_usage_string); list_common_cmds_help(); exit(0); } - else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) { + if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) { printf("usage: %s\n\n", git_usage_string); list_commands(); - exit(0); + } + + else if (!strcmp(help_cmd, "--web") || !strcmp(help_cmd, "-w")) { + show_html_page(argc > 2 ? argv[2] : NULL); + } + + else if (!strcmp(help_cmd, "--info") || !strcmp(help_cmd, "-i")) { + show_info_page(argc > 2 ? argv[2] : NULL); } else