From 482cce820554809c02bc639bb33462f9905e4342 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 2 Feb 2008 07:32:33 +0100 Subject: help: make 'git-help--browse' usable outside 'git-help'. "git-help--browse" helper is to launch a browser of the user's choice to view the HTML version of git documentation for a given command. It used to take the name of a command, convert it to the path of the documentation by prefixing the directory name and appending the ".html" suffix, and start the browser on the path. This updates the division of labor between the caller in help.c and git-help--browser helper. The helper is now responsible for launching a browser of the user's choice on given URLs, and it is the caller's responsibility to tell it the paths to documentation files. This is in preparation to reuse the logic to choose user's preferred browser in instaweb. The helper had a provision for running it without any command name, in which case it showed the toplevel "git(7)" documentation, but the caller in help.c never makes such a call. The helper now exits with a usage message when no path is given. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 92341c4..a03fd2e 100644 --- a/Makefile +++ b/Makefile @@ -819,6 +819,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS) help.o: help.c common-cmds.h GIT-CFLAGS $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \ + '-DGIT_HTML_PATH="$(htmldir_SQ)"' \ '-DGIT_MAN_PATH="$(mandir_SQ)"' \ '-DGIT_INFO_PATH="$(infodir_SQ)"' $< @@ -839,7 +840,6 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.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 $@+ $@ diff --git a/git-help--browse.sh b/git-help--browse.sh index 10b0a36..88608bd 100755 --- a/git-help--browse.sh +++ b/git-help--browse.sh @@ -16,18 +16,13 @@ # git maintainer. # -USAGE='[--browser=browser|--tool=browser] [cmd to display] ...' +USAGE='[--browser=browser|--tool=browser] url/file ...' # This must be capable of running outside of git directory, so # the vanilla git-sh-setup should not be used. NONGIT_OK=Yes . git-sh-setup -# Install data. -html_dir="@@HTMLDIR@@" - -test -f "$html_dir/git.html" || die "No documentation directory found." - valid_tool() { case "$1" in firefox | iceweasel | konqueror | w3m | links | lynx | dillo) @@ -71,6 +66,8 @@ do shift done +test $# = 0 && usage + if test -z "$browser" then for opt in "help.browser" "web.browser" @@ -113,16 +110,13 @@ else fi fi -pages=$(for p in "$@"; do echo "$html_dir/$p.html" ; done) -test -z "$pages" && pages="$html_dir/git.html" - case "$browser" in firefox|iceweasel) # Check version because firefox < 2.0 does not support "-new-tab". vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*') NEWTAB='-new-tab' test "$vers" -lt 2 && NEWTAB='' - nohup "$browser_path" $NEWTAB $pages & + nohup "$browser_path" $NEWTAB "$@" & ;; konqueror) case "$(basename "$browser_path")" in @@ -130,20 +124,20 @@ case "$browser" in # It's simpler to use kfmclient to open a new tab in konqueror. browser_path="$(echo "$browser_path" | sed -e 's/konqueror$/kfmclient/')" type "$browser_path" > /dev/null 2>&1 || die "No '$browser_path' found." - eval "$browser_path" newTab $pages + eval "$browser_path" newTab "$@" ;; kfmclient) - eval "$browser_path" newTab $pages + eval "$browser_path" newTab "$@" ;; *) - nohup "$browser_path" $pages & + nohup "$browser_path" "$@" & ;; esac ;; w3m|links|lynx) - eval "$browser_path" $pages + eval "$browser_path" "$@" ;; dillo) - nohup "$browser_path" $pages & + nohup "$browser_path" "$@" & ;; esac diff --git a/help.c b/help.c index 1302a61..b929899 100644 --- a/help.c +++ b/help.c @@ -328,10 +328,26 @@ static void show_info_page(const char *git_cmd) execlp("info", "info", "gitman", page, NULL); } +static void get_html_page_path(struct strbuf *page_path, const char *page) +{ + struct stat st; + + /* Check that we have a git documentation directory. */ + if (stat(GIT_HTML_PATH "/git.html", &st) || !S_ISREG(st.st_mode)) + die("'%s': not a documentation directory.", GIT_HTML_PATH); + + strbuf_init(page_path, 0); + strbuf_addf(page_path, GIT_HTML_PATH "/%s.html", page); +} + static void show_html_page(const char *git_cmd) { const char *page = cmd_to_page(git_cmd); - execl_git_cmd("help--browse", page, NULL); + struct strbuf page_path; /* it leaks but we exec bellow */ + + get_html_page_path(&page_path, page); + + execl_git_cmd("help--browse", page_path.buf, NULL); } void help_unknown_cmd(const char *cmd) -- cgit v0.10.2-6-g49f6 From caa87713bca77c441c09282aa5b18b179bcfa90d Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 2 Feb 2008 07:32:41 +0100 Subject: help--browse: add '--config' option to check a config option for a browser. The value of this new command line option will be used as a key to check the configuration for an help browser. This should remove the last bit in 'git-help--browse' that was specific to 'git-help', so that other git command can use 'git-help--browse'. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/git-help--browse.sh b/git-help--browse.sh index 88608bd..8ed489d 100755 --- a/git-help--browse.sh +++ b/git-help--browse.sh @@ -16,7 +16,7 @@ # git maintainer. # -USAGE='[--browser=browser|--tool=browser] url/file ...' +USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...' # This must be capable of running outside of git directory, so # the vanilla git-sh-setup should not be used. @@ -53,6 +53,18 @@ do shift ;; esac ;; + -c|--config*) + case "$#,$1" in + *,*=*) + conf=`expr "z$1" : 'z-[^=]*=\(.*\)'` + ;; + 1,*) + usage ;; + *) + conf="$2" + shift ;; + esac + ;; --) break ;; @@ -70,15 +82,16 @@ test $# = 0 && usage if test -z "$browser" then - for opt in "help.browser" "web.browser" + for opt in "$conf" "web.browser" do + test -z "$opt" && continue browser="`git config $opt`" test -z "$browser" || break done if test -n "$browser" && ! valid_tool "$browser"; then - echo >&2 "git config option $opt set to unknown browser: $browser" - echo >&2 "Resetting to default..." - unset browser + echo >&2 "git config option $opt set to unknown browser: $browser" + echo >&2 "Resetting to default..." + unset browser fi fi diff --git a/help.c b/help.c index b929899..058a397 100644 --- a/help.c +++ b/help.c @@ -347,7 +347,7 @@ static void show_html_page(const char *git_cmd) get_html_page_path(&page_path, page); - execl_git_cmd("help--browse", page_path.buf, NULL); + execl_git_cmd("help--browse", "-c", "help.browser", page_path.buf, NULL); } void help_unknown_cmd(const char *cmd) -- cgit v0.10.2-6-g49f6 From 5884f1fe96b33d9666a78e660042b1e3e5f9f4d9 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 2 Feb 2008 07:32:53 +0100 Subject: Rename 'git-help--browse.sh' to 'git-web--browse.sh'. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt index fb77ca3..ad41aab 100644 --- a/Documentation/git-help.txt +++ b/Documentation/git-help.txt @@ -47,19 +47,19 @@ OPTIONS + 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-help--browse' helper script +these config variables is set, the 'git-web--browse' helper script (called by 'git-help') will pick a suitable default. + You can explicitly provide a full path to your preferred 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-help--browse' assumes the tool +'browser.firefox.path'. Otherwise, 'git-web--browse' 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. + -The following browsers are currently supported by 'git-help--browse': +The following browsers are currently supported by 'git-web--browse': + * firefox (this is the default under X Window when not using KDE) * iceweasel diff --git a/Makefile b/Makefile index a03fd2e..d288378 100644 --- a/Makefile +++ b/Makefile @@ -231,7 +231,7 @@ SCRIPT_SH = \ git-lost-found.sh git-quiltimport.sh git-submodule.sh \ git-filter-branch.sh \ git-stash.sh \ - git-help--browse.sh + git-web--browse.sh SCRIPT_PERL = \ git-add--interactive.perl \ diff --git a/git-help--browse.sh b/git-help--browse.sh deleted file mode 100755 index 8ed489d..0000000 --- a/git-help--browse.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/sh -# -# This program launch a web browser on the html page -# describing a git command. -# -# Copyright (c) 2007 Christian Couder -# Copyright (c) 2006 Theodore Y. Ts'o -# -# This file is heavily stolen from git-mergetool.sh, by -# Theodore Y. Ts'o (thanks) that is: -# -# Copyright (c) 2006 Theodore Y. Ts'o -# -# This file is licensed under the GPL v2, or a later version -# at the discretion of Junio C Hamano or any other official -# git maintainer. -# - -USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...' - -# This must be capable of running outside of git directory, so -# the vanilla git-sh-setup should not be used. -NONGIT_OK=Yes -. git-sh-setup - -valid_tool() { - case "$1" in - firefox | iceweasel | konqueror | w3m | links | lynx | dillo) - ;; # happy - *) - return 1 - ;; - esac -} - -init_browser_path() { - browser_path=`git config browser.$1.path` - test -z "$browser_path" && browser_path=$1 -} - -while test $# != 0 -do - case "$1" in - -b|--browser*|-t|--tool*) - case "$#,$1" in - *,*=*) - browser=`expr "z$1" : 'z-[^=]*=\(.*\)'` - ;; - 1,*) - usage ;; - *) - browser="$2" - shift ;; - esac - ;; - -c|--config*) - case "$#,$1" in - *,*=*) - conf=`expr "z$1" : 'z-[^=]*=\(.*\)'` - ;; - 1,*) - usage ;; - *) - conf="$2" - shift ;; - esac - ;; - --) - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift -done - -test $# = 0 && usage - -if test -z "$browser" -then - for opt in "$conf" "web.browser" - do - test -z "$opt" && continue - browser="`git config $opt`" - test -z "$browser" || break - done - if test -n "$browser" && ! valid_tool "$browser"; then - echo >&2 "git config option $opt set to unknown browser: $browser" - echo >&2 "Resetting to default..." - unset browser - fi -fi - -if test -z "$browser" ; then - if test -n "$DISPLAY"; then - browser_candidates="firefox iceweasel konqueror w3m links lynx dillo" - if test "$KDE_FULL_SESSION" = "true"; then - browser_candidates="konqueror $browser_candidates" - fi - else - browser_candidates="w3m links lynx" - fi - - for i in $browser_candidates; do - init_browser_path $i - if type "$browser_path" > /dev/null 2>&1; then - browser=$i - break - fi - done - test -z "$browser" && die "No known browser available." -else - valid_tool "$browser" || die "Unknown browser '$browser'." - - init_browser_path "$browser" - - if ! type "$browser_path" > /dev/null 2>&1; then - die "The browser $browser is not available as '$browser_path'." - fi -fi - -case "$browser" in - firefox|iceweasel) - # Check version because firefox < 2.0 does not support "-new-tab". - vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*') - NEWTAB='-new-tab' - test "$vers" -lt 2 && NEWTAB='' - nohup "$browser_path" $NEWTAB "$@" & - ;; - konqueror) - case "$(basename "$browser_path")" in - konqueror) - # It's simpler to use kfmclient to open a new tab in konqueror. - browser_path="$(echo "$browser_path" | sed -e 's/konqueror$/kfmclient/')" - type "$browser_path" > /dev/null 2>&1 || die "No '$browser_path' found." - eval "$browser_path" newTab "$@" - ;; - kfmclient) - eval "$browser_path" newTab "$@" - ;; - *) - nohup "$browser_path" "$@" & - ;; - esac - ;; - w3m|links|lynx) - eval "$browser_path" "$@" - ;; - dillo) - nohup "$browser_path" "$@" & - ;; -esac diff --git a/git-web--browse.sh b/git-web--browse.sh new file mode 100755 index 0000000..8ed489d --- /dev/null +++ b/git-web--browse.sh @@ -0,0 +1,156 @@ +#!/bin/sh +# +# This program launch a web browser on the html page +# describing a git command. +# +# Copyright (c) 2007 Christian Couder +# Copyright (c) 2006 Theodore Y. Ts'o +# +# This file is heavily stolen from git-mergetool.sh, by +# Theodore Y. Ts'o (thanks) that is: +# +# Copyright (c) 2006 Theodore Y. Ts'o +# +# This file is licensed under the GPL v2, or a later version +# at the discretion of Junio C Hamano or any other official +# git maintainer. +# + +USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...' + +# This must be capable of running outside of git directory, so +# the vanilla git-sh-setup should not be used. +NONGIT_OK=Yes +. git-sh-setup + +valid_tool() { + case "$1" in + firefox | iceweasel | konqueror | w3m | links | lynx | dillo) + ;; # happy + *) + return 1 + ;; + esac +} + +init_browser_path() { + browser_path=`git config browser.$1.path` + test -z "$browser_path" && browser_path=$1 +} + +while test $# != 0 +do + case "$1" in + -b|--browser*|-t|--tool*) + case "$#,$1" in + *,*=*) + browser=`expr "z$1" : 'z-[^=]*=\(.*\)'` + ;; + 1,*) + usage ;; + *) + browser="$2" + shift ;; + esac + ;; + -c|--config*) + case "$#,$1" in + *,*=*) + conf=`expr "z$1" : 'z-[^=]*=\(.*\)'` + ;; + 1,*) + usage ;; + *) + conf="$2" + shift ;; + esac + ;; + --) + break + ;; + -*) + usage + ;; + *) + break + ;; + esac + shift +done + +test $# = 0 && usage + +if test -z "$browser" +then + for opt in "$conf" "web.browser" + do + test -z "$opt" && continue + browser="`git config $opt`" + test -z "$browser" || break + done + if test -n "$browser" && ! valid_tool "$browser"; then + echo >&2 "git config option $opt set to unknown browser: $browser" + echo >&2 "Resetting to default..." + unset browser + fi +fi + +if test -z "$browser" ; then + if test -n "$DISPLAY"; then + browser_candidates="firefox iceweasel konqueror w3m links lynx dillo" + if test "$KDE_FULL_SESSION" = "true"; then + browser_candidates="konqueror $browser_candidates" + fi + else + browser_candidates="w3m links lynx" + fi + + for i in $browser_candidates; do + init_browser_path $i + if type "$browser_path" > /dev/null 2>&1; then + browser=$i + break + fi + done + test -z "$browser" && die "No known browser available." +else + valid_tool "$browser" || die "Unknown browser '$browser'." + + init_browser_path "$browser" + + if ! type "$browser_path" > /dev/null 2>&1; then + die "The browser $browser is not available as '$browser_path'." + fi +fi + +case "$browser" in + firefox|iceweasel) + # Check version because firefox < 2.0 does not support "-new-tab". + vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*') + NEWTAB='-new-tab' + test "$vers" -lt 2 && NEWTAB='' + nohup "$browser_path" $NEWTAB "$@" & + ;; + konqueror) + case "$(basename "$browser_path")" in + konqueror) + # It's simpler to use kfmclient to open a new tab in konqueror. + browser_path="$(echo "$browser_path" | sed -e 's/konqueror$/kfmclient/')" + type "$browser_path" > /dev/null 2>&1 || die "No '$browser_path' found." + eval "$browser_path" newTab "$@" + ;; + kfmclient) + eval "$browser_path" newTab "$@" + ;; + *) + nohup "$browser_path" "$@" & + ;; + esac + ;; + w3m|links|lynx) + eval "$browser_path" "$@" + ;; + dillo) + nohup "$browser_path" "$@" & + ;; +esac diff --git a/help.c b/help.c index 058a397..c35912b 100644 --- a/help.c +++ b/help.c @@ -347,7 +347,7 @@ static void show_html_page(const char *git_cmd) get_html_page_path(&page_path, page); - execl_git_cmd("help--browse", "-c", "help.browser", page_path.buf, NULL); + execl_git_cmd("web--browse", "-c", "help.browser", page_path.buf, NULL); } void help_unknown_cmd(const char *cmd) -- cgit v0.10.2-6-g49f6 From 2e0c290299e381884e4f4a4efb847fc8ecc4647c Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 2 Feb 2008 07:32:56 +0100 Subject: instaweb: use 'git-web--browse' to launch browser. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/git-instaweb.sh b/git-instaweb.sh index 3e4452b..6f91c8f 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -24,8 +24,6 @@ restart restart the web server fqgitdir="$GIT_DIR" local="`git config --bool --get instaweb.local`" httpd="`git config --get instaweb.httpd`" -browser="`git config --get instaweb.browser`" -test -z "$browser" && browser="`git config --get web.browser`" port=`git config --get instaweb.port` module_path="`git config --get instaweb.modulepath`" @@ -36,9 +34,6 @@ conf="$GIT_DIR/gitweb/httpd.conf" # if installed, it doesn't need further configuration (module_path) test -z "$httpd" && httpd='lighttpd -f' -# probably the most popular browser among gitweb users -test -z "$browser" && browser='firefox' - # any untaken local port will do... test -z "$port" && port=1234 @@ -274,14 +269,11 @@ webrick) ;; esac -init_browser_path() { - browser_path="`git config browser.$1.path`" - test -z "$browser_path" && browser_path="$1" -} - start_httpd url=http://127.0.0.1:$port -test -n "$browser" && { - init_browser_path "$browser" - "$browser_path" $url -} || echo $url + +if test -n "$browser"; then + git web--browse -b "$browser" $url || echo $url +else + git web--browse -c "instaweb.browser" $url || echo $url +fi -- cgit v0.10.2-6-g49f6 From a0685a4f45ac8916212188032f75d4acb4031089 Mon Sep 17 00:00:00 2001 From: Dmitry Potapov Date: Sat, 9 Feb 2008 23:22:22 -0800 Subject: git-web--browse: do not start the browser with nohup There is no good reason to run GUI browsers using "nohup". It does not solve any real problem but creates annoying "nohup.out" files in every directory where git help -w is run. Signed-off-by: Dmitry Potapov Signed-off-by: Junio C Hamano diff --git a/git-web--browse.sh b/git-web--browse.sh index 8ed489d..2c51f36 100755 --- a/git-web--browse.sh +++ b/git-web--browse.sh @@ -129,7 +129,7 @@ case "$browser" in vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*') NEWTAB='-new-tab' test "$vers" -lt 2 && NEWTAB='' - nohup "$browser_path" $NEWTAB "$@" & + "$browser_path" $NEWTAB "$@" & ;; konqueror) case "$(basename "$browser_path")" in @@ -143,7 +143,7 @@ case "$browser" in eval "$browser_path" newTab "$@" ;; *) - nohup "$browser_path" "$@" & + "$browser_path" "$@" & ;; esac ;; @@ -151,6 +151,6 @@ case "$browser" in eval "$browser_path" "$@" ;; dillo) - nohup "$browser_path" "$@" & + "$browser_path" "$@" & ;; esac -- cgit v0.10.2-6-g49f6 From 897d39ced4a670dd46df489b25561926dfb011dc Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 8 Feb 2008 13:33:51 +0000 Subject: Adjust .gitignore for 5884f1(Rename 'git-help--browse.sh'...) Since git-help--browse was renamed, we should ignore git-web--browse instead. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano diff --git a/.gitignore b/.gitignore index 7f8421d..165b256 100644 --- a/.gitignore +++ b/.gitignore @@ -50,7 +50,6 @@ git-gc git-get-tar-commit-id git-grep git-hash-object -git-help--browse git-http-fetch git-http-push git-imap-send @@ -136,6 +135,7 @@ git-upload-pack git-var git-verify-pack git-verify-tag +git-web--browse git-whatchanged git-write-tree git-core-*/?* -- cgit v0.10.2-6-g49f6 From b261ec463a4c117aa7961fd3667ffafe0f9ee986 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 9 Feb 2008 07:10:57 +0100 Subject: Documentation: instaweb: add 'git-web--browse' information. Now that 'git-instaweb' uses 'git-web--browse', update the documentation accordingly. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt index 841e8fa..a1456ab 100644 --- a/Documentation/git-instaweb.txt +++ b/Documentation/git-instaweb.txt @@ -38,10 +38,23 @@ OPTIONS The port number to bind the httpd to. (Default: 1234) -b|--browser:: - - The web browser command-line to execute to view the gitweb page. - If blank, the URL of the gitweb instance will be printed to - stdout. (Default: 'firefox') + The web browser that should be used to view the gitweb + page. This will be passed to the 'git-web--browse' helper + script along with the URL of the gitweb instance. If the + script fails, the URL will be printed to stdout. ++ +Note that the 'git-web--browse' script tries, as much as possible, to +display the HTML page in a new tab on an already opened browser. ++ +The following browsers are currently supported by 'git-web--browse': ++ +* firefox (this is the default under X Window when not using KDE) +* iceweasel +* konqueror (this is the default under KDE) +* w3m (this is the default outside X Window) +* links +* lynx +* dillo --start:: Start the httpd instance and exit. This does not generate @@ -74,6 +87,12 @@ You may specify configuration in your .git/config If the configuration variable 'instaweb.browser' is not set, 'web.browser' will be used instead if it is defined. +You can explicitly provide a full path to your preferred 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-web--browse' assumes the tool +is available in PATH. + Author ------ Written by Eric Wong -- cgit v0.10.2-6-g49f6 From 193ad4f63c511948050079ddbe8c9b7342bf85a4 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 9 Feb 2008 07:11:01 +0100 Subject: web--browse: Add a few quotes in 'init_browser_path'. These changes were made to the 'init_browser_path' function in 'git-instaweb.sh', but was not in 'git-web--browse.sh'. [jc: the quoting was screwy and did not quote $1 correctly, so I fixed it up.] Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/git-web--browse.sh b/git-web--browse.sh index 2c51f36..3ade500 100755 --- a/git-web--browse.sh +++ b/git-web--browse.sh @@ -34,8 +34,8 @@ valid_tool() { } init_browser_path() { - browser_path=`git config browser.$1.path` - test -z "$browser_path" && browser_path=$1 + browser_path=$(git "config browser.$1.path") + test -z "$browser_path" && browser_path="$1" } while test $# != 0 -- cgit v0.10.2-6-g49f6 From 8e08689959a78bb4f27e010fbd225b4bf3addadb Mon Sep 17 00:00:00 2001 From: "jaysoffian+git@gmail.com" Date: Mon, 11 Feb 2008 10:57:34 -0500 Subject: git-web--browse: fix misplaced quote in init_browser_path() git "config browser.$1.path" should be git config "browser.$1.path" Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano diff --git a/git-web--browse.sh b/git-web--browse.sh index 3ade500..fbf29cb 100755 --- a/git-web--browse.sh +++ b/git-web--browse.sh @@ -34,7 +34,7 @@ valid_tool() { } init_browser_path() { - browser_path=$(git "config browser.$1.path") + browser_path=$(git config "browser.$1.path") test -z "$browser_path" && browser_path="$1" } -- cgit v0.10.2-6-g49f6 From cb45f83cbdfcde4333ea5982b3c763e136fc599c Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Thu, 14 Feb 2008 08:01:23 +0100 Subject: Documentation: add 'git-web--browse.txt' and simplify other docs. 'git-help.txt' and 'git-instaweb.txt' contained duplicated information about 'git-web--browse'. This patch puts this information where it belongs. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt index ad41aab..0926dc1 100644 --- a/Documentation/git-help.txt +++ b/Documentation/git-help.txt @@ -48,26 +48,8 @@ OPTIONS 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-web--browse' helper script -(called by 'git-help') will pick a suitable default. -+ -You can explicitly provide a full path to your preferred 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-web--browse' 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. -+ -The following browsers are currently supported by 'git-web--browse': -+ -* firefox (this is the default under X Window when not using KDE) -* iceweasel -* konqueror (this is the default under KDE) -* w3m (this is the default outside X Window) -* links -* lynx -* dillo +(called by 'git-help') will pick a suitable default. See +linkgit:git-web--browse[1] for more information about this. CONFIGURATION VARIABLES ----------------------- @@ -84,7 +66,7 @@ line option: The 'help.browser', 'web.browser' and 'browser..path' will also be checked if the 'web' format is chosen (either by command line option or configuration variable). See '-w|--web' in the OPTIONS -section above. +section above and linkgit:git-web--browse[1]. Note that these configuration variables should probably be set using the '--global' flag, for example like this: diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt index a1456ab..51f1532 100644 --- a/Documentation/git-instaweb.txt +++ b/Documentation/git-instaweb.txt @@ -40,21 +40,9 @@ OPTIONS -b|--browser:: The web browser that should be used to view the gitweb page. This will be passed to the 'git-web--browse' helper - script along with the URL of the gitweb instance. If the - script fails, the URL will be printed to stdout. -+ -Note that the 'git-web--browse' script tries, as much as possible, to -display the HTML page in a new tab on an already opened browser. -+ -The following browsers are currently supported by 'git-web--browse': -+ -* firefox (this is the default under X Window when not using KDE) -* iceweasel -* konqueror (this is the default under KDE) -* w3m (this is the default outside X Window) -* links -* lynx -* dillo + script along with the URL of the gitweb instance. See + linkgit:git-web--browse[1] for more information about this. If + the script fails, the URL will be printed to stdout. --start:: Start the httpd instance and exit. This does not generate @@ -85,13 +73,8 @@ You may specify configuration in your .git/config ----------------------------------------------------------------------- If the configuration variable 'instaweb.browser' is not set, -'web.browser' will be used instead if it is defined. - -You can explicitly provide a full path to your preferred 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-web--browse' assumes the tool -is available in PATH. +'web.browser' will be used instead if it is defined. See +linkgit:git-web--browse[1] for more information about this. Author ------ diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt new file mode 100644 index 0000000..df57d01 --- /dev/null +++ b/Documentation/git-web--browse.txt @@ -0,0 +1,78 @@ +git-web--browse(1) +================== + +NAME +---- +git-web--browse - git helper script to launch a web browser + +SYNOPSIS +-------- +'git-web--browse' [OPTIONS] URL/FILE ... + +DESCRIPTION +----------- + +This script tries, as much as possible, to display the URLs and FILEs +that are passed as arguments, as HTML pages in new tabs on an already +opened web browser. + +The following browsers (or commands) are currently supported: + +* firefox (this is the default under X Window when not using KDE) +* iceweasel +* konqueror (this is the default under KDE) +* w3m (this is the default outside graphical environments) +* links +* lynx +* dillo +* open (this is the default under Mac OS X GUI) + +OPTIONS +------- +-b BROWSER|--browser=BROWSER:: + Use the specified BROWSER. It must be in the list of supported + browsers. + +-t BROWSER|--tool=BROWSER:: + Same as above. + +-c CONF.VAR|--config=CONF.VAR:: + CONF.VAR is looked up in the git config files. If it's set, + then its value specify the browser that should be used. + +CONFIGURATION VARIABLES +----------------------- + +The web browser can be specified using a configuration variable passed +with the -c (or --config) command line option, or the 'web.browser' +configuration variable if the former is not used. + +You can explicitly provide a full path to your preferred 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-web--browse' assumes the tool +is available in PATH. + +Note that these configuration variables should probably be set using +the '--global' flag, for example like this: + +------------------------------------------------ +$ git config --global web.browser firefox +------------------------------------------------ + +as they are probably more user specific than repository specific. +See linkgit:git-config[1] for more information about this. + +Author +------ +Written by Christian Couder and the git-list +, based on git-mergetool by Theodore Y. Ts'o. + +Documentation +------------- +Documentation by Christian Couder and the +git-list . + +GIT +--- +Part of the linkgit:git[7] suite -- cgit v0.10.2-6-g49f6