git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] git-instaweb: Three fixes and one improvement
@ 2010-12-29 16:43 Jakub Narebski
  2010-12-29 16:47 ` [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server Jakub Narebski
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jakub Narebski @ 2010-12-29 16:43 UTC (permalink / raw)
  To: git; +Cc: Tadeusz Sosnierz, Eric Wong

Actually only the first patch is a proper bugfix for issue noticed by
Tadeusz Sośnierz ('tadzik' on github, https://github.com/tadzik) in
GitHub private message; second and third are hardening git-instaweb
against differences in configuration and environment.

Junio, could you at least apply the first one before 1.7.4?  This is a
fix for a real bug, if for not often used "git instaweb 
--httpd=plackup".

tadzik, does the first patch fixes the issue you noticed?

Jakub Narebski (4):
  git-instaweb: Fix issue with static files for 'plackup' server
  git-instaweb: Static files are under "static/" in gitweb_conf
  git-instaweb: Add checks that web server can be started and is
    started
  git-instaweb: Use "git-instaweb" as sitename (for page titles)

 git-instaweb.sh |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

-- 
Jakub Narębski
Poland

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server
  2010-12-29 16:43 [PATCH 0/4] git-instaweb: Three fixes and one improvement Jakub Narebski
@ 2010-12-29 16:47 ` Jakub Narebski
  2010-12-29 23:24   ` Junio C Hamano
  2010-12-29 23:52   ` Junio C Hamano
  2010-12-29 16:48 ` [PATCH 2/4] git-instaweb: Static files are under "static/" in gitweb_conf Jakub Narebski
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Jakub Narebski @ 2010-12-29 16:47 UTC (permalink / raw)
  To: git; +Cc: Tadeusz Sosnierz, Eric Wong

The default (in gitweb/Makefile) is to use relative paths for gitweb
static files, e.g. "static/gitweb.css" for GITWEB_CSS.  But the
configuration for Plack::Middleware::Static in plackup_conf assumed
that static files must be absolute paths starting with "/gitweb/"
prefix which had to be stripped, e.g. "/gitweb/static/gitweb.css".
This in turn caused web server run by "git instaweb --httpd=plackup"
to not access static files (e.g. CSS) correctly.

This is a minimal fixup, making 'plackup' web server in git-instaweb
work with default gitweb build configuration.

Reported-by: Tadeusz Sośnierz <tadzikes@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
The regexp is probably too strict: qr{^/static/} should be enough,
but I didn't want to change too much at once.

This bug was not noticed because we don't have any test for
git-instaweb, not mentioning tests for all web servers supported.  And
the fact that I was checking "git instaweb -httpd=plackup" against
gitweb.cgi built with custom configuration (including the fact that
GITWEB_CSS="/gitweb/static/gitweb.css").

tadzik, does that fix the issue you noticed?

Junio, could you apply this before 1.7.4?  Thanks in advance.

 git-instaweb.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-instaweb.sh b/git-instaweb.sh
index 10fcebb..bb57d81 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -549,7 +549,7 @@ my \$app = builder {
 	};
 	# serve static files, i.e. stylesheet, images, script
 	enable 'Static',
-		path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
+		path => qr{^/static/.*(?:js|css|png)\$},
 		root => "$root/",
 		encoding => 'utf-8'; # encoding for 'text/plain' files
 	# convert CGI application to PSGI app
-- 
1.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] git-instaweb: Static files are under "static/" in gitweb_conf
  2010-12-29 16:43 [PATCH 0/4] git-instaweb: Three fixes and one improvement Jakub Narebski
  2010-12-29 16:47 ` [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server Jakub Narebski
@ 2010-12-29 16:48 ` Jakub Narebski
  2010-12-29 16:49 ` [PATCH 3/4] git-instaweb: Add checks that web server can be started and is started Jakub Narebski
  2010-12-29 16:50 ` [PATCH 4/4] git-instaweb: Use "git-instaweb" as sitename (for page titles) Jakub Narebski
  3 siblings, 0 replies; 9+ messages in thread
From: Jakub Narebski @ 2010-12-29 16:48 UTC (permalink / raw)
  To: git; +Cc: Tadeusz Sosnierz, Eric Wong

The variables used to compose links for gitweb static files,
i.e. @stylesheets / $stylesheet, $logo, etc. are configurable via
GITWEB_CSS, GITWEB_LOGO, etc. gitweb build configuration variables.
The installation directory of those static files is currently always
set to $(gitwebdir)/static.  Thus git-instaweb could rely on the place
where those files are installed, but not on $logo, $favicon
etc. variables.

Set @stylesheets, $logo, $favicon and $javascript to their default
values in gitweb config file for git-instaweb (in gitweb_conf
function), so that web servers invoked by git-instaweb (for example
Plack::Middleware::Static component for 'plackup' web server) can
correctly serve links to those static files.

We assume here that git-instaweb uses modern gitweb with names of
gitweb config variables as mentioned above.

Note that we had to take care that possible optional minimizations of
stylesheet and of javascript is correctly taken into account.


This is continuation of fixup for issue noticed by Tadeusz Sośnierz
with --httpd=plackup and gitweb stylesheet (CSS).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
The subject (commit description) is not the best, but that is what I
was able to come up with.

This doesn't matter for default configuration and setup, but it allows
me to use my custom gitweb build configuration without any changes in
result.

 git-instaweb.sh |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/git-instaweb.sh b/git-instaweb.sh
index bb57d81..da569f2 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -581,6 +581,11 @@ our \$projectroot = "$(dirname "$fqgitdir")";
 our \$git_temp = "$fqgitdir/gitweb/tmp";
 our \$projects_list = \$projectroot;
 
+our @stylesheets = ("static/".basename(\$stylesheets[0]));
+our \$logo = "static/git-logo.png";
+our \$favicon = "static/git-favicon.png";
+our \$javascript = "static/".basename(\$javascript);
+
 \$feature{'remote_heads'}{'default'} = [1];
 EOF
 }
-- 
1.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] git-instaweb: Add checks that web server can be started and is started
  2010-12-29 16:43 [PATCH 0/4] git-instaweb: Three fixes and one improvement Jakub Narebski
  2010-12-29 16:47 ` [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server Jakub Narebski
  2010-12-29 16:48 ` [PATCH 2/4] git-instaweb: Static files are under "static/" in gitweb_conf Jakub Narebski
@ 2010-12-29 16:49 ` Jakub Narebski
  2010-12-29 16:50 ` [PATCH 4/4] git-instaweb: Use "git-instaweb" as sitename (for page titles) Jakub Narebski
  3 siblings, 0 replies; 9+ messages in thread
From: Jakub Narebski @ 2010-12-29 16:49 UTC (permalink / raw)
  To: git; +Cc: Eric Wong

Better to check that "$root/gitweb.cgi" exists, and that web server
started, rather than have (for example) the following error message

  $ git instaweb --httpd=plackup --browser=mozilla
  Waiting for 'plackup' to start .../usr/share/gitweb/gitweb.cgi:
  No such file or directory at <somewhere>/perl5/CGI/Compile.pm line 97.
  ........

and keep waiting in httpd_is_ready for gitweb.cgi which would not start.

Note that the first check is not strictly necessary, but checking
separately that gitweb.cgi script can be found at expected place leads
to better error message.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
It can be considered bugfix, or it can be considered hardening of
git-instaweb (making it more resilent).

 git-instaweb.sh |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/git-instaweb.sh b/git-instaweb.sh
index da569f2..94f8b07 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -41,6 +41,9 @@ test -z "$root" && root='@@GITWEBDIR@@'
 # any untaken local port will do...
 test -z "$port" && port=1234
 
+# Sanity check
+test -e "$root/gitweb.cgi" || die "gitweb.cgi not found at '$root'"
+
 resolve_full_httpd () {
 	case "$httpd" in
 	*apache2*|*lighttpd*|*httpd*)
@@ -617,7 +620,7 @@ webrick)
 	;;
 esac
 
-start_httpd
+start_httpd || die "Could not start '$httpd'"
 url=http://127.0.0.1:$port
 
 if test -n "$browser"; then
-- 
1.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] git-instaweb: Use "git-instaweb" as sitename (for page titles)
  2010-12-29 16:43 [PATCH 0/4] git-instaweb: Three fixes and one improvement Jakub Narebski
                   ` (2 preceding siblings ...)
  2010-12-29 16:49 ` [PATCH 3/4] git-instaweb: Add checks that web server can be started and is started Jakub Narebski
@ 2010-12-29 16:50 ` Jakub Narebski
  2010-12-30  6:23   ` Eric Wong
  3 siblings, 1 reply; 9+ messages in thread
From: Jakub Narebski @ 2010-12-29 16:50 UTC (permalink / raw)
  To: git; +Cc: Eric Wong

The default is to use "$ENV{'SERVER_NAME'} Git" or "Untitled Git";
use "git-instaweb" instead.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is new feature, and doesn't need to be in 1.7.4

It would be an RFC, if not for the fact that it is such trivial change.

 git-instaweb.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/git-instaweb.sh b/git-instaweb.sh
index 94f8b07..935515d 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -583,6 +583,7 @@ gitweb_conf() {
 our \$projectroot = "$(dirname "$fqgitdir")";
 our \$git_temp = "$fqgitdir/gitweb/tmp";
 our \$projects_list = \$projectroot;
+our \$site_name = "git-instaweb";
 
 our @stylesheets = ("static/".basename(\$stylesheets[0]));
 our \$logo = "static/git-logo.png";
-- 
1.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server
  2010-12-29 16:47 ` [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server Jakub Narebski
@ 2010-12-29 23:24   ` Junio C Hamano
  2010-12-29 23:52   ` Junio C Hamano
  1 sibling, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2010-12-29 23:24 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Tadeusz Sosnierz, Eric Wong

Jakub Narebski <jnareb@gmail.com> writes:

> The default (in gitweb/Makefile) is to use relative paths for gitweb
> static files, e.g. "static/gitweb.css" for GITWEB_CSS.  But the
> configuration for Plack::Middleware::Static in plackup_conf assumed
> that static files must be absolute paths starting with "/gitweb/"
> prefix which had to be stripped, e.g. "/gitweb/static/gitweb.css".
> This in turn caused web server run by "git instaweb --httpd=plackup"
> to not access static files (e.g. CSS) correctly.
>
> This is a minimal fixup, making 'plackup' web server in git-instaweb
> work with default gitweb build configuration.
>
> Reported-by: Tadeusz Sośnierz <tadzikes@gmail.com>
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> ---
> The regexp is probably too strict: qr{^/static/} should be enough,
> but I didn't want to change too much at once.
>
> This bug was not noticed because we don't have any test for
> git-instaweb, not mentioning tests for all web servers supported.  And
> the fact that I was checking "git instaweb -httpd=plackup" against
> gitweb.cgi built with custom configuration (including the fact that
> GITWEB_CSS="/gitweb/static/gitweb.css").
>
> tadzik, does that fix the issue you noticed?
>
> Junio, could you apply this before 1.7.4?

Hmph, I was kind of hoping that I can issue 1.7.3.5 tonight...

>
>  git-instaweb.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-instaweb.sh b/git-instaweb.sh
> index 10fcebb..bb57d81 100755
> --- a/git-instaweb.sh
> +++ b/git-instaweb.sh
> @@ -549,7 +549,7 @@ my \$app = builder {
>  	};
>  	# serve static files, i.e. stylesheet, images, script
>  	enable 'Static',
> -		path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
> +		path => qr{^/static/.*(?:js|css|png)\$},
>  		root => "$root/",
>  		encoding => 'utf-8'; # encoding for 'text/plain' files
>  	# convert CGI application to PSGI app
> -- 
> 1.7.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server
  2010-12-29 16:47 ` [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server Jakub Narebski
  2010-12-29 23:24   ` Junio C Hamano
@ 2010-12-29 23:52   ` Junio C Hamano
  2010-12-30  0:40     ` Jakub Narebski
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2010-12-29 23:52 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Tadeusz Sosnierz, Eric Wong

Jakub Narebski <jnareb@gmail.com> writes:

> The default (in gitweb/Makefile) is to use relative paths for gitweb
> static files, e.g. "static/gitweb.css" for GITWEB_CSS.  But the
> configuration for Plack::Middleware::Static in plackup_conf assumed
> that static files must be absolute paths starting with "/gitweb/"
> prefix which had to be stripped, e.g. "/gitweb/static/gitweb.css".
> This in turn caused web server run by "git instaweb --httpd=plackup"
> to not access static files (e.g. CSS) correctly.
>
> This is a minimal fixup, making 'plackup' web server in git-instaweb
> work with default gitweb build configuration.
>
> Reported-by: Tadeusz Sośnierz <tadzikes@gmail.com>
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> ---
> The regexp is probably too strict: qr{^/static/} should be enough,
> but I didn't want to change too much at once.
>
> This bug was not noticed because we don't have any test for
> git-instaweb, not mentioning tests for all web servers supported.  And
> the fact that I was checking "git instaweb -httpd=plackup" against
> gitweb.cgi built with custom configuration (including the fact that
> GITWEB_CSS="/gitweb/static/gitweb.css").
>
> tadzik, does that fix the issue you noticed?
>
> Junio, could you apply this before 1.7.4?  Thanks in advance.
>
>  git-instaweb.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-instaweb.sh b/git-instaweb.sh
> index 10fcebb..bb57d81 100755
> --- a/git-instaweb.sh
> +++ b/git-instaweb.sh
> @@ -549,7 +549,7 @@ my \$app = builder {
>  	};
>  	# serve static files, i.e. stylesheet, images, script
>  	enable 'Static',
> -		path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
> +		path => qr{^/static/.*(?:js|css|png)\$},

I wonder if you meant qr{^/static/.*\\.(?:js|css|png)\$} here, to make
sure that these three tokens are file suffixes, not just random
substring.

>  		root => "$root/",
>  		encoding => 'utf-8'; # encoding for 'text/plain' files
>  	# convert CGI application to PSGI app
> -- 
> 1.7.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server
  2010-12-29 23:52   ` Junio C Hamano
@ 2010-12-30  0:40     ` Jakub Narebski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Narebski @ 2010-12-30  0:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Tadeusz Sosnierz, Eric Wong

On Thu, 30 Dec 2010, Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > The default (in gitweb/Makefile) is to use relative paths for gitweb
> > static files, e.g. "static/gitweb.css" for GITWEB_CSS.  But the
> > configuration for Plack::Middleware::Static in plackup_conf assumed
> > that static files must be absolute paths starting with "/gitweb/"
> > prefix which had to be stripped, e.g. "/gitweb/static/gitweb.css".
> > This in turn caused web server run by "git instaweb --httpd=plackup"
> > to not access static files (e.g. CSS) correctly.
> >
> > This is a minimal fixup, making 'plackup' web server in git-instaweb
> > work with default gitweb build configuration.
> >
> > Reported-by: Tadeusz Sośnierz <tadzikes@gmail.com>
> > Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> > ---
> > The regexp is probably too strict: qr{^/static/} should be enough,
> > but I didn't want to change too much at once.
[...]
> > diff --git a/git-instaweb.sh b/git-instaweb.sh
> > index 10fcebb..bb57d81 100755
> > --- a/git-instaweb.sh
> > +++ b/git-instaweb.sh
> > @@ -549,7 +549,7 @@ my \$app = builder {
> >  	};
> >  	# serve static files, i.e. stylesheet, images, script
> >  	enable 'Static',
> > -		path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
> > +		path => qr{^/static/.*(?:js|css|png)\$},
> 
> I wonder if you meant qr{^/static/.*\\.(?:js|css|png)\$} here, to make
> sure that these three tokens are file suffixes, not just random
> substring.

Yes, it should be qr{^/static/.*\\.(?:js|css|png)\$} though as I said:
"The regexp is probably too strict: qr{^/static/} should be enough,"

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] git-instaweb: Use "git-instaweb" as sitename (for page titles)
  2010-12-29 16:50 ` [PATCH 4/4] git-instaweb: Use "git-instaweb" as sitename (for page titles) Jakub Narebski
@ 2010-12-30  6:23   ` Eric Wong
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Wong @ 2010-12-30  6:23 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Jakub Narebski <jnareb@gmail.com> wrote:
> This is new feature, and doesn't need to be in 1.7.4
> 
> It would be an RFC, if not for the fact that it is such trivial change.

Thanks Jakub.  This series all looks reasonable to me (untested).

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-12-30  6:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-29 16:43 [PATCH 0/4] git-instaweb: Three fixes and one improvement Jakub Narebski
2010-12-29 16:47 ` [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server Jakub Narebski
2010-12-29 23:24   ` Junio C Hamano
2010-12-29 23:52   ` Junio C Hamano
2010-12-30  0:40     ` Jakub Narebski
2010-12-29 16:48 ` [PATCH 2/4] git-instaweb: Static files are under "static/" in gitweb_conf Jakub Narebski
2010-12-29 16:49 ` [PATCH 3/4] git-instaweb: Add checks that web server can be started and is started Jakub Narebski
2010-12-29 16:50 ` [PATCH 4/4] git-instaweb: Use "git-instaweb" as sitename (for page titles) Jakub Narebski
2010-12-30  6:23   ` Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).