Skip to content

Commit bf901f8

Browse files
jnarebgitster
authored andcommitted
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>
1 parent 718a087 commit bf901f8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

gitweb/gitweb.perl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,7 @@ sub git_get_heads_list {
22332233
my ($hash, $name, $title) = split(' ', $refinfo, 3);
22342234
my ($committer, $epoch, $tz) =
22352235
($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
2236+
$ref_item{'fullname'} = $name;
22362237
$name =~ s!^refs/heads/!!;
22372238

22382239
$ref_item{'name'} = $name;
@@ -2270,6 +2271,7 @@ sub git_get_tags_list {
22702271
my ($id, $type, $name, $refid, $reftype, $title) = split(' ', $refinfo, 6);
22712272
my ($creator, $epoch, $tz) =
22722273
($creatorinfo =~ /^(.*) ([0-9]+) (.*)$/);
2274+
$ref_item{'fullname'} = $name;
22732275
$name =~ s!^refs/tags/!!;
22742276

22752277
$ref_item{'type'} = $type;
@@ -3690,8 +3692,8 @@ sub git_tags_body {
36903692
"<td class=\"link\">" . " | " .
36913693
$cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'})}, $tag{'reftype'});
36923694
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");
36953697
} elsif ($tag{'reftype'} eq "blob") {
36963698
print " | " . $cgi->a({-href => href(action=>"blob_plain", hash=>$tag{'refid'})}, "raw");
36973699
}
@@ -3726,13 +3728,13 @@ sub git_heads_body {
37263728
$alternate ^= 1;
37273729
print "<td><i>$ref{'age'}</i></td>\n" .
37283730
($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'}),
37303732
-class => "list name"},esc_html($ref{'name'})) .
37313733
"</td>\n" .
37323734
"<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") .
37363738
"</td>\n" .
37373739
"</tr>";
37383740
}

0 commit comments

Comments
 (0)