X-Git-Url: https://git.ladys.computer/Gitweb/blobdiff_plain/300c72789d367d12189cb6fa7e9ac9ffcb242433ecc210c3fb2a56ae127c0759..5ca6347a26ce3cd988a527f9624d3463e4850d568df6ea9b85d972fdd4bf4d5c:/gitweb.cgi diff --git a/gitweb.cgi b/gitweb.cgi index 77e64dd..0698b74 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "229"; +my $version = "234"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -480,11 +480,11 @@ sub git_read_commit { } my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'}); if ($age > 60*60*24*7*2) { - $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon, $mday; + $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday; $co{'age_string_age'} = $co{'age_string'}; } else { $co{'age_string_date'} = $co{'age_string'}; - $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon, $mday; + $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday; } return %co; } @@ -607,6 +607,21 @@ sub file_type { } } +sub format_log_line_html { + my $line = shift; + + $line = escapeHTML($line); + $line =~ s/ / /g; + if ($line =~ m/([0-9a-fA-F]{40})/) { + my $hash_text = $1; + if (git_get_type($hash_text) eq "commit") { + my $link = $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=commit;h=$hash_text"}, $hash_text); + $line =~ s/$hash_text/$link/; + } + } + return $line; +} + sub date_str { my $epoch = shift; my $tz = shift || "-0000"; @@ -1395,7 +1410,7 @@ sub git_log { } else { $empty = 0; } - print escapeHTML($line) . "
\n"; + print format_log_line_html($line) . "
\n"; } if (!$empty) { print "
\n"; @@ -1496,7 +1511,7 @@ sub git_commit { print "" . escapeHTML($line) . "
\n"; } else { $signed = 0; - print escapeHTML($line) . "
\n"; + print format_log_line_html($line) . "
\n"; } } print "\n"; @@ -1525,7 +1540,7 @@ sub git_commit { print "\n"; } $alternate ^= 1; - if ($status eq "N") { + if ($status eq "A") { my $mode_chng = ""; if (S_ISREG(oct $to_mode)) { $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777); @@ -1687,7 +1702,7 @@ sub git_commitdiff { } else { $empty = 0; } - print escapeHTML($line) . "
\n"; + print format_log_line_html($line) . "
\n"; } print "
\n"; foreach my $line (@difftree) { @@ -1700,7 +1715,7 @@ sub git_commitdiff { my $to_id = $4; my $status = $5; my $file = $6; - if ($status eq "N") { + if ($status eq "A") { print "
" . file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id) . "(new)" . "
\n"; @@ -1732,25 +1747,51 @@ sub git_commitdiff_plain { my (@difftree) = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); + # 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{'id'}} = $tag{'name'}; + } + open $fd, "-|", "$gitbin/git-rev-list HEAD"; + while (my $commit = <$fd>) { + chomp $commit; + if ($taghash{$commit}) { + $tagname = $taghash{$commit}; + } + if ($commit eq $hash) { + last; + } + } + close $fd; + + print $cgi->header(-type => "text/plain", -charset => 'utf-8'); my %co = git_read_commit($hash); my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); - print $cgi->header(-type => "text/plain", -charset => 'utf-8'); my $comment = $co{'comment'}; - print "Author: $co{'author'}\n" . + print "From: $co{'author'}\n" . "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n". - "Source: $my_url?p=$project;a=commitdiff;h=$hash\n" . + "Subject: $co{'title'}\n"; + if (defined $tagname) { + print "X-Git-Tag: $tagname\n"; + } + print "X-Git-Url: $my_url?p=$project;a=commitdiff;h=$hash\n" . "\n"; + foreach my $line (@$comment) {; print " $line\n"; } - print "\n"; + print "---\n\n"; + foreach my $line (@difftree) { $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/; my $from_id = $3; my $to_id = $4; my $status = $5; my $file = $6; - if ($status eq "N") { + if ($status eq "A") { git_diff_print(undef, "/dev/null", $to_id, "b/$file", "plain"); } elsif ($status eq "D") { git_diff_print($from_id, "a/$file", undef, "/dev/null", "plain");