gitweb: disambiguate heads and tags withs the same name
Avoid wrong disambiguation that would link logs/trees of tags and heads which share the same name to the same page, leading to a disambiguation that would prefer the tag, thus making it impossible to access the corresponding head log and tree without hacking the url by hand. It does it by using full refname (with 'refs/heads/' or 'refs/tags/' prefix) instead of shortened one in the URLs in 'heads' and 'tags' tables. This makes URLs (and refs) provided by gitweb unambiguous. Signed-off-by: Guillaume Seguin <guillaume@segu.in> Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jakub Narebski committed
Dec 15, 2007 at 15:40 UTC
bf901f8e748144a19d057d9d00582417d480c795
1 file changed
+8
-6
gitweb/gitweb.perl
+8
-6
@@ -2233,6 +2233,7 @@ sub git_get_heads_list {
2233
my ($hash, $name, $title) = split(' ', $refinfo, 3);
2234
my ($committer, $epoch, $tz) =
2235
($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
2236
+ $ref_item{'fullname'} = $name;
2237
$name =~ s!^refs/heads/!!;
2238
2239
$ref_item{'name'} = $name;
@@ -2270,6 +2271,7 @@ sub git_get_tags_list {
2271
my ($id, $type, $name, $refid, $reftype, $title) = split(' ', $refinfo, 6);
2272
my ($creator, $epoch, $tz) =
2273
($creatorinfo =~ /^(.*) ([0-9]+) (.*)$/);
2274
+ $ref_item{'fullname'} = $name;
2275
$name =~ s!^refs/tags/!!;
2276
2277
$ref_item{'type'} = $type;
@@ -3690,8 +3692,8 @@ sub git_tags_body {
3692
"<td class=\"link\">" . " | " .
3693
$cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'})}, $tag{'reftype'});
3694
if ($tag{'reftype'} eq "commit") {
3693
- print " | " . $cgi->a({-href => href(action=>"shortlog", hash=>$tag{'name'})}, "shortlog") .
3694
- " | " . $cgi->a({-href => href(action=>"log", hash=>$tag{'name'})}, "log");
3695
+ print " | " . $cgi->a({-href => href(action=>"shortlog", hash=>$tag{'fullname'})}, "shortlog") .
3696
+ " | " . $cgi->a({-href => href(action=>"log", hash=>$tag{'fullname'})}, "log");
3697
} elsif ($tag{'reftype'} eq "blob") {
3698
print " | " . $cgi->a({-href => href(action=>"blob_plain", hash=>$tag{'refid'})}, "raw");
3699
}
@@ -3726,13 +3728,13 @@ sub git_heads_body {
3728
$alternate ^= 1;
3729
print "<td><i>$ref{'age'}</i></td>\n" .
3730
($curr ? "<td class=\"current_head\">" : "<td>") .
3729
- $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'name'}),
3731
+ $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'fullname'}),
3732
-class => "list name"},esc_html($ref{'name'})) .
3733
"</td>\n" .
3734
"<td class=\"link\">" .
3733
- $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'name'})}, "shortlog") . " | " .
3734
- $cgi->a({-href => href(action=>"log", hash=>$ref{'name'})}, "log") . " | " .
3735
- $cgi->a({-href => href(action=>"tree", hash=>$ref{'name'}, hash_base=>$ref{'name'})}, "tree") .
3735
+ $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'fullname'})}, "shortlog") . " | " .
3736
+ $cgi->a({-href => href(action=>"log", hash=>$ref{'fullname'})}, "log") . " | " .
3737
+ $cgi->a({-href => href(action=>"tree", hash=>$ref{'fullname'}, hash_base=>$ref{'name'})}, "tree") .
3738
"</td>\n" .
3739
"</tr>";
3740
}