Code

gitweb: Add links to blobdiffs in from-file/to-file header for merges
authorJakub Narebski <jnareb@gmail.com>
Fri, 8 Jun 2007 11:32:44 +0000 (13:32 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 10 Jun 2007 23:57:48 +0000 (16:57 -0700)
Add links to diff to file ('blobdiff' view) for each of individual
versions of the file in a merge commit to the from-file/to-file header
in the patch part of combined 'commitdiff' view for merges.

The from-file/to-file header for combined diff now looks like:

  --- _1_/_git-gui/git-gui.sh_
  --- _2_/_git-gui.sh_
  +++ b/_git-gui/git-gui.sh_

where _<filename>_ link is link to appropriate version of a file
('blob' view), and _<n>_ is link to respective diff to mentioned
version of a file ('blobdiff' view). There is even hint provided in
the form of title attribute.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl

index 13114bc9c62015ebbc50ded7caf2912aea5ee069..c7acfade608ce3b6e49c9d061896dcb4bd96c2e0 100755 (executable)
@@ -1058,7 +1058,7 @@ sub format_extended_diff_header_line {
 
 # format from-file/to-file diff header
 sub format_diff_from_to_header {
-       my ($from_line, $to_line, $diffinfo, $from, $to) = @_;
+       my ($from_line, $to_line, $diffinfo, $from, $to, @parents) = @_;
        my $line;
        my $result = '';
 
@@ -1084,7 +1084,17 @@ sub format_diff_from_to_header {
                for (my $i = 0; $i < $diffinfo->{'nparents'}; $i++) {
                        if ($from->{'href'}[$i]) {
                                $line = '--- ' .
-                                       ($i+1) . "/" .
+                                       $cgi->a({-href=>href(action=>"blobdiff",
+                                                            hash_parent=>$diffinfo->{'from_id'}[$i],
+                                                            hash_parent_base=>$parents[$i],
+                                                            file_parent=>$from->{'file'}[$i],
+                                                            hash=>$diffinfo->{'to_id'},
+                                                            hash_base=>$hash,
+                                                            file_name=>$to->{'file'}),
+                                                -class=>"path",
+                                                -title=>"diff" . ($i+1)},
+                                               $i+1) .
+                                       '/' .
                                        $cgi->a({-href=>$from->{'href'}[$i], -class=>"path"},
                                                esc_path($from->{'file'}[$i]));
                        } else {
@@ -3042,7 +3052,8 @@ sub git_patchset_body {
                #assert($patch_line =~ m/^\+\+\+/) if DEBUG;
 
                print format_diff_from_to_header($last_patch_line, $patch_line,
-                                                $diffinfo, \%from, \%to);
+                                                $diffinfo, \%from, \%to,
+                                                @hash_parents);
 
                # the patch itself
        LINE: