@matheusbsbs / matheus-bagliano / commits / 91af4ce4ec
Fork 0

gitweb: Add links to blobdiffs in from-file/to-file header for merges

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>

Jakub Narebski committed Jun 8, 2007 at 13:32 UTC 91af4ce4ec3f39e1190ab702f51f141e18cdcc1e
1 file changed +14 -3
gitweb/gitweb.perl
+14 -3
@@ -1058,7 +1058,7 @@ sub format_extended_diff_header_line {
1058
1059 # format from-file/to-file diff header
1060 sub format_diff_from_to_header {
1061 - my ($from_line, $to_line, $diffinfo, $from, $to) = @_;
1061 + my ($from_line, $to_line, $diffinfo, $from, $to, @parents) = @_;
1062 my $line;
1063 my $result = '';
1064
@@ -1084,7 +1084,17 @@ sub format_diff_from_to_header {
1084 for (my $i = 0; $i < $diffinfo->{'nparents'}; $i++) {
1085 if ($from->{'href'}[$i]) {
1086 $line = '--- ' .
1087 - ($i+1) . "/" .
1087 + $cgi->a({-href=>href(action=>"blobdiff",
1088 + hash_parent=>$diffinfo->{'from_id'}[$i],
1089 + hash_parent_base=>$parents[$i],
1090 + file_parent=>$from->{'file'}[$i],
1091 + hash=>$diffinfo->{'to_id'},
1092 + hash_base=>$hash,
1093 + file_name=>$to->{'file'}),
1094 + -class=>"path",
1095 + -title=>"diff" . ($i+1)},
1096 + $i+1) .
1097 + '/' .
1098 $cgi->a({-href=>$from->{'href'}[$i], -class=>"path"},
1099 esc_path($from->{'file'}[$i]));
1100 } else {
@@ -3042,7 +3052,8 @@ sub git_patchset_body {
3052 #assert($patch_line =~ m/^\+\+\+/) if DEBUG;
3053
3054 print format_diff_from_to_header($last_patch_line, $patch_line,
3045 - $diffinfo, \%from, \%to);
3055 + $diffinfo, \%from, \%to,
3056 + @hash_parents);
3057
3058 # the patch itself
3059 LINE: