summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5ad9db3)
raw | patch | inline | side by side (parent: 5ad9db3)
author | Christian Couder <chriscool@tuxfamily.org> | |
Fri, 14 Mar 2008 04:56:49 +0000 (05:56 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 14 Mar 2008 07:31:06 +0000 (00:31 -0700) |
Currently "git web--browse" is restricted to a set of commands defined
in the script. You can subvert the "browser.<tool>.path" to force "git
web--browse" to use a different command, but if you have a command
whose invocation syntax does not match one of the current tools then
you would have to write a wrapper script for it.
This patch adds a git config variable "browser.<tool>.cmd" which
allows a more flexible browser choice.
If you run "git web--browse" with -t/--tool, -b/--browser or the
"web.browser" config variable set to an unrecognized tool then "git
web--browse" will query the "browser.<tool>.cmd" config variable. If
this variable exists, then "git web--browse" will treat the specified
tool as a custom command and will use a shell eval to run the command
with the URLs added as extra parameters.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
in the script. You can subvert the "browser.<tool>.path" to force "git
web--browse" to use a different command, but if you have a command
whose invocation syntax does not match one of the current tools then
you would have to write a wrapper script for it.
This patch adds a git config variable "browser.<tool>.cmd" which
allows a more flexible browser choice.
If you run "git web--browse" with -t/--tool, -b/--browser or the
"web.browser" config variable set to an unrecognized tool then "git
web--browse" will query the "browser.<tool>.cmd" config variable. If
this variable exists, then "git web--browse" will treat the specified
tool as a custom command and will use a shell eval to run the command
with the URLs added as extra parameters.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-web--browse.sh | patch | blob | history |
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 1023b9085989aecfdcdc161232ee22de866d5f57..384148a59fc492d8fb1d6ea4fc4532aa1e5ffc22 100755 (executable)
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
NONGIT_OK=Yes
. git-sh-setup
+valid_custom_tool()
+{
+ browser_cmd="$(git config "browser.$1.cmd")"
+ test -n "$browser_cmd"
+}
+
valid_tool() {
case "$1" in
firefox | iceweasel | konqueror | w3m | links | lynx | dillo | open)
;; # happy
*)
- return 1
+ valid_custom_tool "$1" || return 1
;;
esac
}
init_browser_path "$browser"
- if ! type "$browser_path" > /dev/null 2>&1; then
+ if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then
die "The browser $browser is not available as '$browser_path'."
fi
fi
dillo)
"$browser_path" "$@" &
;;
+ *)
+ if test -n "$browser_cmd"; then
+ ( eval $browser_cmd "$@" )
+ fi
+ ;;
esac