From 822f7c7349d61f6075961ce42c1bd1a85cf999e5 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sun, 23 Sep 2007 22:42:08 +0200 Subject: Supplant the "while case ... break ;; esac" idiom A lot of shell scripts contained stuff starting with while case "$#" in 0) break ;; esac and similar. I consider breaking out of the condition instead of the body od the loop ugly, and the implied "true" value of the non-matching case is not really obvious to humans at first glance. It happens not to be obvious to some BSD shells, either, but that's because they are not POSIX-compliant. In most cases, this has been replaced by a straight condition using "test". "case" has the advantage of being faster than "test" on vintage shells where "test" is not a builtin. Since none of them is likely to run the git scripts, anyway, the added readability should be worth the change. A few loops have had their termination condition expressed differently. Signed-off-by: David Kastrup Signed-off-by: Junio C Hamano --- git-instaweb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-instaweb.sh') diff --git a/git-instaweb.sh b/git-instaweb.sh index b79c6b6a42..f5629e7439 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -61,7 +61,7 @@ stop_httpd () { test -f "$fqgitdir/pid" && kill `cat "$fqgitdir/pid"` } -while case "$#" in 0) break ;; esac +while test $# != 0 do case "$1" in --stop|stop) -- cgit v1.3-5-g9baa From 14b45b66e7f75341040c9797af60fb9318c8b047 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 6 Oct 2007 13:29:48 -0400 Subject: instaweb: allow for use of auto-generated scripts this patch allows scripts that reside in $fqgitdir/gitweb to be used for firing up an instaweb server. this lays the groundwork for extending instaweb support to non-standard web servers, which may require a script for proper invocation. Signed-off-by: Mike Dalessio Signed-off-by: Lars Hjemli Signed-off-by: Shawn O. Pearce --- git-instaweb.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git-instaweb.sh') diff --git a/git-instaweb.sh b/git-instaweb.sh index f5629e7439..8eb7f3ed1a 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -37,7 +37,9 @@ start_httpd () { else # many httpds are installed in /usr/sbin or /usr/local/sbin # these days and those are not in most users $PATHs - for i in /usr/local/sbin /usr/sbin + # in addition, we may have generated a server script + # in $fqgitdir/gitweb. + for i in /usr/local/sbin /usr/sbin "$fqgitdir/gitweb" do if test -x "$i/$httpd_only" then -- cgit v1.3-5-g9baa From 425b78e886e80f3c9f845edebfb199719a8f2d87 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 6 Oct 2007 13:29:49 -0400 Subject: instaweb: support for Ruby's WEBrick server running the webrick server with git requires Ruby and Ruby's YAML and Webrick libraries (both of which come standard with Ruby). nice for single-user standalone invocations. the --httpd=webrick option generates a ruby script on the fly to read httpd.conf options and invoke the web server via library call. this script is placed in the .git/gitweb directory. it also generates a shell script in a feeble attempt to invoke ruby in a portable manner, which assumes that 'ruby' is in the user's $PATH. Signed-off-by: Mike Dalessio Signed-off-by: Lars Hjemli Signed-off-by: Shawn O. Pearce --- Documentation/git-instaweb.txt | 2 +- git-instaweb.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) (limited to 'git-instaweb.sh') diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt index cec60ee780..735008c1ab 100644 --- a/Documentation/git-instaweb.txt +++ b/Documentation/git-instaweb.txt @@ -27,7 +27,7 @@ OPTIONS The HTTP daemon command-line that will be executed. Command-line options may be specified here, and the configuration file will be added at the end of the command-line. - Currently, lighttpd and apache2 are the only supported servers. + Currently lighttpd, apache2 and webrick are supported. (Default: lighttpd) -m|--module-path:: diff --git a/git-instaweb.sh b/git-instaweb.sh index 8eb7f3ed1a..2e4eeccace 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -139,6 +139,43 @@ GIT_DIR="$fqgitdir" export GIT_EXEC_PATH GIT_DIR +webrick_conf () { + # generate a standalone server script in $fqgitdir/gitweb. + cat >"$fqgitdir/gitweb/$httpd.rb" <"$fqgitdir/gitweb/$httpd" <"$conf" <> "$conf" +} + lighttpd_conf () { cat > "$conf" <