From e24c76bf09576e0d197db1e40dff655a75e9efe1 Mon Sep 17 00:00:00 2001 From: Sean Estabrooks Date: Sat, 18 Jul 2009 09:45:44 -0700 Subject: Trivial path quoting fixes in git-instaweb Bodo Schlecht noticed that Instaweb didn't propely quote all path instances in the Apache config file it generated. Acked-by: Eric Wong Signed-off-by: Junio C Hamano --- git-instaweb.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-instaweb.sh') diff --git a/git-instaweb.sh b/git-instaweb.sh index 5f4419b69b..32f6496b0d 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -256,7 +256,7 @@ apache2_conf () { mkdir -p "$GIT_DIR/gitweb/logs" bind= test x"$local" = xtrue && bind='127.0.0.1:' - echo 'text/css css' > $fqgitdir/mime.types + echo 'text/css css' > "$fqgitdir/mime.types" cat > "$conf" <> "$conf" < Date: Sat, 8 Aug 2009 18:24:02 -0400 Subject: git-instaweb: fix mod_perl detection for apache2 The script was looking for something that matched the '^our $gitbin' regex, which no longer exists in gitweb.cgi. Now it looks for 'MOD_PERL', which should be on the line that checks to see if the script is running in a mod_perl environment. Signed-off-by: Mark Rada 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 32f6496b0d..5f5cac75ea 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -278,7 +278,7 @@ EOF # check to see if Dennis Stosberg's mod_perl compatibility patch # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied - if test -f "$module_path/mod_perl.so" && grep '^our $gitbin' \ + if test -f "$module_path/mod_perl.so" && grep 'MOD_PERL' \ "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null then # favor mod_perl if available -- cgit v1.2.3 From 0ded47581aa6097f1a685443d3c2fc0cebaf8c3c Mon Sep 17 00:00:00 2001 From: Wilhansen Li Date: Fri, 21 Aug 2009 22:24:48 +0800 Subject: Add support for the Mongoose web server. Mongoose (http://code.google.com/p/mongoose/) is a lightweight web server. It's just a single binary so it's a lot simpler to configure and install. Signed-off-by: Wilhansen Li Signed-off-by: Junio C Hamano --- git-instaweb.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) (limited to 'git-instaweb.sh') diff --git a/git-instaweb.sh b/git-instaweb.sh index 5f5cac75ea..d96eddbe56 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -77,11 +77,30 @@ start_httpd () { resolve_full_httpd # don't quote $full_httpd, there can be arguments to it (-f) - $full_httpd "$fqgitdir/gitweb/httpd.conf" - if test $? != 0; then - echo "Could not execute http daemon $httpd." - exit 1 - fi + case "$httpd" in + *mongoose*) + #The mongoose server doesn't have a daemon mode so we'll have to fork it + $full_httpd "$fqgitdir/gitweb/httpd.conf" & + #Save the pid before doing anything else (we'll print it later) + pid=$! + + if test $? != 0; then + echo "Could not execute http daemon $httpd." + exit 1 + fi + + cat > "$fqgitdir/pid" < "$conf" < Date: Tue, 1 Sep 2009 13:39:17 +0200 Subject: gitweb: Incremental blame (using JavaScript) Add 'blame_incremental' view, which uses "git blame --incremental" and JavaScript (Ajax), where 'blame' use "git blame --porcelain". * gitweb generates initial info by putting file contents (from "git cat-file") together with line numbers in blame table * then gitweb makes web browser JavaScript engine call startBlame() function from gitweb.js * startBlame() opens XMLHttpRequest connection to 'blame_data' view, which in turn calls "git blame --incremental" for a file, and streams output of git-blame to JavaScript (gitweb.js) * XMLHttpRequest event handler updates line info in blame view as soon as it gets data from 'blame_data' (from server), and it also updates progress info * when 'blame_data' ends, and gitweb.js finishes updating line info, it fixes colors to match (as far as possible) ordinary 'blame' view, and updates information about how long it took to generate page. Gitweb deals with streamed 'blame_data' server errors by displaying them in the progress info area (just in case). The 'blame_incremental' view tries to be equivalent to 'blame' action; there are however a few differences in output between 'blame' and 'blame_incremental' view: * 'blame_incremental' always used query form for this part of link(s) which is generated by JavaScript code. The difference is visible if we use path_info link (pass some or all arguments in path_info). Changing this would require implementing something akin to href() subroutine from gitweb.perl in JavaScript (in gitweb.js). * 'blame_incremental' always uses "rowspan" attribute, even if rowspan="1". This simplifies code, and is not visible to user. * The progress bar and progress info are still there even after JavaScript part of 'blame_incremental' finishes work. Note that currently no link generated by gitweb leads to this new view. This code is based on patch by Petr Baudis patch, which in turn was tweaked up version of Fredrik Kuivinen 's proof of concept patch. This patch adds GITWEB_JS compile configuration option, and modifies git-instaweb.sh to take gitweb.js into account. The code for git-instaweb.sh was taken from Pasky's patch. Signed-off-by: Fredrik Kuivinen Signed-off-by: Petr Baudis Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- git-instaweb.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'git-instaweb.sh') diff --git a/git-instaweb.sh b/git-instaweb.sh index 5f4419b69b..6f381c88da 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -331,8 +331,15 @@ gitweb_css () { EOFGITWEB } +gitweb_js () { + cat > "$1" <<\EOFGITWEB +@@GITWEB_JS@@ +EOFGITWEB +} + gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi" gitweb_css "$GIT_DIR/gitweb/gitweb.css" +gitweb_js "$GIT_DIR/gitweb/gitweb.js" case "$httpd" in *lighttpd*) -- cgit v1.2.3 From 10d1432aece21ac65a89fe962b1c3019ec1f46e0 Mon Sep 17 00:00:00 2001 From: Mark Rada Date: Sat, 26 Sep 2009 14:12:32 -0400 Subject: instaweb: support mod_cgid for apache2 Some people have mod_cgid instead of mod_cgi, most likely as a result of choosing a threaded MPM. In cases where the user has both modules, mod_cgi will be preferred in order to maintain a simpler setup. This patch also causes instaweb to print a message and die in cases where there is no module that instaweb knows how to handle. Signed-off-by: Mark Rada Signed-off-by: Shawn O. Pearce --- git-instaweb.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'git-instaweb.sh') diff --git a/git-instaweb.sh b/git-instaweb.sh index d96eddbe56..622a5f0eb2 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -317,7 +317,21 @@ EOF resolve_full_httpd list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/") $list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \ - echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf" + if test -f "$module_path/mod_cgi.so" + then + echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf" + else + $list_mods | grep 'mod_cgid\.c' >/dev/null 2>&1 || \ + if test -f "$module_path/mod_cgid.so" + then + echo "LoadModule cgid_module $module_path/mod_cgid.so" \ + >> "$conf" + else + echo "You have no CGI support!" + exit 2 + fi + echo "ScriptSock logs/gitweb.sock" >> "$conf" + fi cat >> "$conf" < -- cgit v1.2.3 From e1622bfcbad680225ad5c337e4778df88389227e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 23 Nov 2009 15:56:32 -0800 Subject: Protect scripted Porcelains from GREP_OPTIONS insanity If the user has exported the GREP_OPTIONS environment variable, the output from "grep" and "egrep" in scripted Porcelains may be different from what they expect. For example, we may want to count number of matching lines, by "grep" piped to "wc -l", and GREP_OPTIONS=-C3 will break such use. The approach taken by this change to address this issue is to protect only our own use of grep/egrep. Because we do not unset it at the beginning of our scripts, hook scripts run from the scripted Porcelains are exposed to the same insanity this environment variable causes when grep/egrep is used to implement logic (e.g. "grep | wc -l"), and it is entirely up to the hook scripts to protect themselves. On the other hand, applypatch-msg hook may want to show offending words in the proposed commit log message using grep to the end user, and the user might want to set GREP_OPTIONS=--color to paint the match more visibly. The approach to protect only our own use without unsetting the environment variable globally will allow this use case. Signed-off-by: Junio C Hamano --- git-instaweb.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git-instaweb.sh') diff --git a/git-instaweb.sh b/git-instaweb.sh index d96eddbe56..84805c61e5 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -41,7 +41,7 @@ resolve_full_httpd () { case "$httpd" in *apache2*|*lighttpd*) # ensure that the apache2/lighttpd command ends with "-f" - if ! echo "$httpd" | grep -- '-f *$' >/dev/null 2>&1 + if ! echo "$httpd" | sane_grep -- '-f *$' >/dev/null 2>&1 then httpd="$httpd -f" fi @@ -297,8 +297,8 @@ EOF # check to see if Dennis Stosberg's mod_perl compatibility patch # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied - if test -f "$module_path/mod_perl.so" && grep 'MOD_PERL' \ - "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null + if test -f "$module_path/mod_perl.so" && + sane_grep 'MOD_PERL' "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null then # favor mod_perl if available cat >> "$conf" </dev/null 2>&1 || \ + $list_mods | sane_grep 'mod_cgi\.c' >/dev/null 2>&1 || \ echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf" cat >> "$conf" < Date: Sun, 22 Nov 2009 23:09:12 -0800 Subject: instaweb: restart server if already running Running 'git instaweb' when an instaweb server is already running will fail (at least when the port is the same) and overwrite the pid file used to track the currently running server. This turns out to be especially annoying when the user tries to stop the previously running server with 'git instaweb --stop' and is instead greeted with an error message because the pid file has been destroyed. Instead of allowing a user to start two instaweb servers, stop the currently running server first and then start the new one. This should be fine because it was never really possible to start two instaweb servers in the first place due to the pid file issue outlined above. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- git-instaweb.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'git-instaweb.sh') diff --git a/git-instaweb.sh b/git-instaweb.sh index d96eddbe56..80a7f74fea 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -73,6 +73,11 @@ resolve_full_httpd () { } start_httpd () { + if test -f "$fqgitdir/pid"; then + say "Instance already running. Restarting..." + stop_httpd + fi + # here $httpd should have a meaningful value resolve_full_httpd -- cgit v1.2.3 From 9524cf29930b4f91d68ad1384d7f984393a54c15 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 26 Jan 2010 15:08:31 -0800 Subject: fix portability issues with $ in double quotes Using a dollar sign in double quotes isn't portable. Escape them with a backslash or replace the double quotes with single quotes. Signed-off-by: Stephen Boyd 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 b8e6456208..6a65f255cc 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -320,7 +320,7 @@ EOF else # plain-old CGI resolve_full_httpd - list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/") + list_mods=$(echo "$full_httpd" | sed 's/-f$/-l/') $list_mods | sane_grep 'mod_cgi\.c' >/dev/null 2>&1 || \ if test -f "$module_path/mod_cgi.so" then -- cgit v1.2.3