gitweb: fix #patchNN anchors when path_info is enabled
commit5e96a847b391eda693b60347bb190dd45fb1721c
authorKevin Cernekee <cernekee@gmail.com>
Fri, 18 Mar 2011 16:00:16 +0000 (18 17:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Mar 2011 19:29:31 +0000 (18 12:29 -0700)
tree532520caf38b33eb5b7cb6b6c3e3439163dc0ea1
parente2a57aac8a8a2b786739a5a93ea9dcfd2f0fd0e2
gitweb: fix #patchNN anchors when path_info is enabled

When $feature{'pathinfo'} is used, gitweb script sets the base URL to
itself, so that relative links to static files work correctly.  It
does it by adding something like below to HTML head:

  <base href="http://HOST/gitweb.cgi">

This breaks the "patch" anchor links seen on the commitdiff pages,
because these links, being relative (<a href="#patch1">), are resolved
(computed) relative to the base URL and not relative to current URL,
i.e. as:

  http://HOST/gitweb.cgi#patch1

Instead, they should look like this:

  http://HOST/gitweb.cgi/myproject.git/commitdiff/35a9811ef9d68eae9afd76bede121da4f89b448c#patch1

Add an "-anchor" parameter to href(), and use href(-anchor=>"patch1")
to generate "patch" anchor links, so that the full path is included in
the patch link.

While at it, convert

  print "foo";
  print "bar";

to

  print "foo" .
        "bar";

in the neighborhood of changes.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl