\n" .
"\n";
- open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed.");
+ open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_head($project) or die_error(undef, "Open failed.");
my (@revlist) = map { chomp; $_ } <$fd>;
close $fd;
print "
\n" .
@@ -1024,15 +1070,19 @@ sub git_summary {
}
$alternate ^= 1;
if ($i-- > 0) {
+ my $ref = "";
+ if (defined $refs->{$commit}) {
+ $ref = "
" . esc_html($refs->{$commit}) . "";
+ }
print "
$co{'age_string'} | \n" .
"
" . esc_html(chop_str($co{'author_name'}, 10)) . " | \n" .
"
";
if (length($co{'title_short'}) < length($co{'title'})) {
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
- "" . esc_html($co{'title_short'}) . "");
+ "" . esc_html($co{'title_short'}) . "$ref");
} else {
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"},
- "" . esc_html($co{'title'}) . "");
+ "" . esc_html($co{'title'}) . "$ref");
}
print " | \n" .
"
" .
@@ -1139,7 +1189,7 @@ sub git_summary {
}
sub git_tag {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
git_header_html();
print "\n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1178,7 +1228,7 @@ sub git_tag {
}
sub git_tags {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
git_header_html();
print " \n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1237,7 +1287,7 @@ sub git_tags {
}
sub git_heads {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
git_header_html();
print " \n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1294,7 +1344,7 @@ sub git_get_hash_by_path {
my $t_mode = $1;
my $t_type = $2;
my $t_hash = $3;
- my $t_name = $4;
+ my $t_name = validate_input(unquote($4));
if ($t_name eq $part) {
if (!(@parts)) {
return $t_hash;
@@ -1310,8 +1360,8 @@ sub git_get_hash_by_path {
sub git_blob {
if (!defined $hash && defined $file_name) {
- my $base = $hash_base || git_read_hash("$project/HEAD");
- $hash = git_get_hash_by_path($base, $file_name, "blob");
+ my $base = $hash_base || git_read_head($project);
+ $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file.");
}
open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed.");
git_header_html();
@@ -1374,13 +1424,13 @@ sub git_blob_plain {
sub git_tree {
if (!defined $hash) {
- $hash = git_read_hash("$project/HEAD");
+ $hash = git_read_head($project);
if (defined $file_name) {
- my $base = $hash_base || git_read_hash("$project/HEAD");
+ my $base = $hash_base || $hash;
$hash = git_get_hash_by_path($base, $file_name, "tree");
}
if (!defined $hash_base) {
- $hash_base = git_read_hash("$project/HEAD");
+ $hash_base = $hash;
}
}
$/ = "\0";
@@ -1389,6 +1439,11 @@ sub git_tree {
close $fd or die_error(undef, "Reading tree failed.");
$/ = "\n";
+ my $refs = read_info_ref();
+ my $ref = "";
+ if (defined $refs->{$hash_base}) {
+ $ref = " " . esc_html($refs->{$hash_base}) . "";
+ }
git_header_html();
my $base_key = "";
my $base = "";
@@ -1404,7 +1459,7 @@ sub git_tree {
"
\n" .
" \n";
print " \n" .
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" .
" \n";
} else {
print " \n";
@@ -1426,7 +1481,6 @@ sub git_tree {
my $t_mode = $1;
my $t_type = $2;
my $t_hash = $3;
- my $t_name = $4;
my $t_name = validate_input($4);
if ($alternate) {
print " \n";
@@ -1460,7 +1514,7 @@ sub git_tree {
sub git_rss {
# http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
- open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed.");
+ open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_head($project) or die_error(undef, "Open failed.");
my (@revlist) = map { chomp; $_ } <$fd>;
close $fd or die_error(undef, "Reading rev-list failed.");
print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
@@ -1529,7 +1583,7 @@ sub git_opml {
foreach my $pr (@list) {
my %proj = %$pr;
- my $head = git_read_hash("$proj{'path'}/HEAD");
+ my $head = git_read_head($proj{'path'});
if (!defined $head) {
next;
}
@@ -1550,13 +1604,14 @@ sub git_opml {
}
sub git_log {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
if (!defined $hash) {
$hash = $head;
}
if (!defined $page) {
$page = 0;
}
+ my $refs = read_info_ref();
git_header_html();
print "\n";
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1599,13 +1654,17 @@ sub git_log {
}
for (my $i = ($page * 100); $i <= $#revlist; $i++) {
my $commit = $revlist[$i];
+ my $ref = "";
+ if (defined $refs->{$commit}) {
+ $ref = " " . esc_html($refs->{$commit}) . "";
+ }
my %co = git_read_commit($commit);
next if !%co;
my %ad = date_str($co{'author_epoch'});
print " \n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "title"},
- "$co{'age_string'}" . esc_html($co{'title'})) . "\n" .
- " \n";
+ " $co{'age_string'}" . esc_html($co{'title'}) . $ref) . "\n";
+ print " \n";
print "\n" .
" \n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
@@ -1663,6 +1722,11 @@ sub git_commit {
if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
$expires = "+1d";
}
+ my $refs = read_info_ref();
+ my $ref = "";
+ if (defined $refs->{$co{'id'}}) {
+ $ref = " " . esc_html($refs->{$co{'id'}}) . "";
+ }
git_header_html(undef, $expires);
print " \n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1676,7 +1740,7 @@ sub git_commit {
"
\n";
if (defined $co{'parent'}) {
print " \n" .
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" .
" \n";
} else {
print " \n" .
@@ -1900,6 +1964,11 @@ sub git_commitdiff {
if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
$expires = "+1d";
}
+ my $refs = read_info_ref();
+ my $ref = "";
+ if (defined $refs->{$co{'id'}}) {
+ $ref = " " . esc_html($refs->{$co{'id'}}) . "";
+ }
git_header_html(undef, $expires);
print " \n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1911,7 +1980,7 @@ sub git_commitdiff {
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" .
" \n";
print " \n" .
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" .
" \n";
print " \n";
my $comment = $co{'comment'};
@@ -1982,23 +2051,18 @@ sub git_commitdiff_plain {
# try to figure out the next tag after this commit
my $tagname;
- my %taghash;
- my $tags = git_read_refs("refs/tags");
- foreach my $entry (@$tags) {
- my %tag = %$entry;
- $taghash{$tag{'refid'}} = $tag{'name'};
- }
+ my $refs = read_info_ref("tags");
open $fd, "-|", "$gitbin/git-rev-list HEAD";
- while (my $commit = <$fd>) {
- chomp $commit;
- if ($taghash{$commit}) {
- $tagname = $taghash{$commit};
+ chomp (my (@commits) = <$fd>);
+ close $fd;
+ foreach my $commit (@commits) {
+ if (defined $refs->{$commit}) {
+ $tagname = $refs->{$commit}
}
if ($commit eq $hash) {
last;
}
}
- close $fd;
print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
my %co = git_read_commit($hash);
@@ -2014,7 +2078,7 @@ sub git_commitdiff_plain {
"\n";
foreach my $line (@$comment) {;
- print " $line\n";
+ print "$line\n";
}
print "---\n\n";
@@ -2036,12 +2100,13 @@ sub git_commitdiff_plain {
sub git_history {
if (!defined $hash) {
- $hash = git_read_hash("$project/HEAD");
+ $hash = git_read_head($project);
}
my %co = git_read_commit($hash);
if (!%co) {
die_error(undef, "Unknown commit object.");
}
+ my $refs = read_info_ref();
git_header_html();
print " \n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -2071,6 +2136,10 @@ sub git_history {
if (!%co) {
next;
}
+ my $ref = "";
+ if (defined $refs->{$commit}) {
+ $ref = " " . esc_html($refs->{$commit}) . "";
+ }
if ($alternate) {
print " \n";
} else {
@@ -2080,7 +2149,7 @@ sub git_history {
print "| $co{'age_string_date'} | \n" .
"" . esc_html(chop_str($co{'author_name'}, 15, 3)) . " | \n" .
"" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "" .
- esc_html(chop_str($co{'title'}, 50)) . "") . " | \n" .
+ esc_html(chop_str($co{'title'}, 50)) . "$ref") . "\n" .
"" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
" | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
@@ -2107,7 +2176,7 @@ sub git_search {
die_error("", "Text field empty.");
}
if (!defined $hash) {
- $hash = git_read_hash("$project/HEAD");
+ $hash = git_read_head($project);
}
my %co = git_read_commit($hash);
if (!%co) {
@@ -2248,13 +2317,14 @@ sub git_search {
}
sub git_shortlog {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
if (!defined $hash) {
$hash = $head;
}
if (!defined $page) {
$page = 0;
}
+ my $refs = read_info_ref();
git_header_html();
print " \n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -2295,6 +2365,10 @@ sub git_shortlog {
my $alternate = 0;
for (my $i = ($page * 100); $i <= $#revlist; $i++) {
my $commit = $revlist[$i];
+ my $ref = "";
+ if (defined $refs->{$commit}) {
+ $ref = " " . esc_html($refs->{$commit}) . "";
+ }
my %co = git_read_commit($commit);
my %ad = date_str($co{'author_epoch'});
if ($alternate) {
@@ -2308,10 +2382,10 @@ sub git_shortlog {
" | ";
if (length($co{'title_short'}) < length($co{'title'})) {
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
- "" . esc_html($co{'title_short'}) . "");
+ "" . esc_html($co{'title_short'}) . "$ref");
} else {
print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"},
- "" . esc_html($co{'title_short'}) . "");
+ "" . esc_html($co{'title_short'}) . "$ref");
}
print " | \n" .
"" .
| |