gitweb: Remove forgotten call to git_to_hash
[gitweb.git] / gitweb / gitweb.perl
index 6d53c8b9563da00254272f4cc7863cbc3b173dd1..68f40bda8f97f4e238d13f0a7f4ad2adafd00198 100755 (executable)
@@ -1358,10 +1358,18 @@ sub git_print_header_div {
 sub git_print_authorship {
        my $co = shift;
 
-       my %ad = parse_date($co->{'author_epoch'});
+       my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
        print "<div class=\"author_date\">" .
              esc_html($co->{'author_name'}) .
-             " [$ad{'rfc2822'}]</div>\n";
+             " [$ad{'rfc2822'}";
+       if ($ad{'hour_local'} < 6) {
+               printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
+                      $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
+       } else {
+               printf(" (%02d:%02d %s)",
+                      $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
+       }
+       print "]</div>\n";
 }
 
 sub git_print_page_path {
@@ -1407,6 +1415,7 @@ ($;%)
        foreach my $line (@$log) {
                if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
                        $signoff = 1;
+                       $empty = 0;
                        if (! $opts{'-remove_signoff'}) {
                                print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
                                next;
@@ -1459,6 +1468,7 @@ sub git_difftree_body {
 
        print "<table class=\"diff_tree\">\n";
        my $alternate = 0;
+       my $patchno = 0;
        foreach my $line (@{$difftree}) {
                my %diff = parse_difftree_raw_line($line);
 
@@ -1499,8 +1509,14 @@ sub git_difftree_body {
                              "<td class=\"link\">" .
                              $cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'},
                                                     hash_base=>$hash, file_name=>$diff{'file'})},
-                                     "blob") .
-                             "</td>\n";
+                                     "blob");
+                       if ($action == "commitdiff") {
+                               # link to patch
+                               $patchno++;
+                               print " | " .
+                                     $cgi->a({-href => "#patch$patchno"}, "patch");
+                       }
+                       print "</td>\n";
 
                } elsif ($diff{'status'} eq "D") { # deleted
                        my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
@@ -1514,8 +1530,14 @@ sub git_difftree_body {
                              $cgi->a({-href => href(action=>"blob", hash=>$diff{'from_id'},
                                                     hash_base=>$parent, file_name=>$diff{'file'})},
                                      "blob") .
-                             " | " .
-                             $cgi->a({-href => href(action=>"history", hash_base=>$parent,
+                             " | ";
+                       if ($action == "commitdiff") {
+                               # link to patch
+                               $patchno++;
+                               print " | " .
+                                     $cgi->a({-href => "#patch$patchno"}, "patch");
+                       }
+                       print $cgi->a({-href => href(action=>"history", hash_base=>$parent,
                                                     file_name=>$diff{'file'})},
                                      "history") .
                              "</td>\n";
@@ -1551,16 +1573,23 @@ sub git_difftree_body {
                        print "</td>\n" .
                              "<td>$mode_chnge</td>\n" .
                              "<td class=\"link\">" .
-                               $cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'},
-                                                      hash_base=>$hash, file_name=>$diff{'file'})},
-                                       "blob");
+                             $cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'},
+                                                    hash_base=>$hash, file_name=>$diff{'file'})},
+                                     "blob");
                        if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
-                               print " | " .
-                                       $cgi->a({-href => href(action=>"blobdiff",
-                                                              hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
-                                                              hash_base=>$hash, hash_parent_base=>$parent,
-                                                              file_name=>$diff{'file'})},
-                                               "diff");
+                               if ($action == "commitdiff") {
+                                       # link to patch
+                                       $patchno++;
+                                       print " | " .
+                                               $cgi->a({-href => "#patch$patchno"}, "patch");
+                               } else {
+                                       print " | " .
+                                               $cgi->a({-href => href(action=>"blobdiff",
+                                                                      hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
+                                                                      hash_base=>$hash, hash_parent_base=>$parent,
+                                                                      file_name=>$diff{'file'})},
+                                                       "diff");
+                               }
                        }
                        print " | " .
                                $cgi->a({-href => href(action=>"history",
@@ -1590,12 +1619,19 @@ sub git_difftree_body {
                                                     hash=>$diff{'to_id'}, file_name=>$diff{'to_file'})},
                                      "blob");
                        if ($diff{'to_id'} ne $diff{'from_id'}) {
-                               print " | " .
-                                       $cgi->a({-href => href(action=>"blobdiff",
-                                                              hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
-                                                              hash_base=>$hash, hash_parent_base=>$parent,
-                                                              file_name=>$diff{'to_file'}, file_parent=>$diff{'from_file'})},
-                                               "diff");
+                               if ($action == "commitdiff") {
+                                       # link to patch
+                                       $patchno++;
+                                       print " | " .
+                                               $cgi->a({-href => "#patch$patchno"}, "patch");
+                               } else {
+                                       print " | " .
+                                               $cgi->a({-href => href(action=>"blobdiff",
+                                                                      hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
+                                                                      hash_base=>$hash, hash_parent_base=>$parent,
+                                                                      file_name=>$diff{'to_file'}, file_parent=>$diff{'from_file'})},
+                                                       "diff");
+                               }
                        }
                        print "</td>\n";
 
@@ -1628,7 +1664,7 @@ sub git_patchset_body {
                                # first patch in patchset
                                $patch_found = 1;
                        }
-                       print "<div class=\"patch\">\n";
+                       print "<div class=\"patch\" id=\"patch". ($patch_idx+1) ."\">\n";
 
                        if (ref($difftree->[$patch_idx]) eq "HASH") {
                                $diffinfo = $difftree->[$patch_idx];
@@ -2742,10 +2778,6 @@ sub git_blobdiff {
                        @difftree
                                or die_error('404 Not Found', "Blob diff not found");
 
-               } elsif (defined $hash) { # try to find filename from $hash
-                       if ($hash !~ /[0-9a-fA-F]{40}/) {
-                               $hash = git_to_hash($hash);
-                       }
                } elsif (defined $hash &&
                         $hash =~ /[0-9a-fA-F]{40}/) {
                        # try to find filename from $hash
@@ -2976,8 +3008,8 @@ sub git_commitdiff {
 
        # write patch
        if ($format eq 'html') {
-               #git_difftree_body(\@difftree, $hash, $hash_parent);
-               #print "<br/>\n";
+               git_difftree_body(\@difftree, $hash, $hash_parent);
+               print "<br/>\n";
 
                git_patchset_body($fd, \@difftree, $hash, $hash_parent);
                close $fd;