gitweb: Add diff tree, with links to patches, to commitdiff view
Added/uncommented git_difftree_body invocation in git_commitdiff. Added anchors (via 'id' attribute) to patches in patchset. git_difftree_body is modified to link to patch anchor when called from git_commitdiff, instead of link to blobdiff. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
fba20b429a
commit
b4657e7759
@ -1460,6 +1460,7 @@ sub git_difftree_body {
|
|||||||
|
|
||||||
print "<table class=\"diff_tree\">\n";
|
print "<table class=\"diff_tree\">\n";
|
||||||
my $alternate = 0;
|
my $alternate = 0;
|
||||||
|
my $patchno = 0;
|
||||||
foreach my $line (@{$difftree}) {
|
foreach my $line (@{$difftree}) {
|
||||||
my %diff = parse_difftree_raw_line($line);
|
my %diff = parse_difftree_raw_line($line);
|
||||||
|
|
||||||
@ -1500,8 +1501,14 @@ sub git_difftree_body {
|
|||||||
"<td class=\"link\">" .
|
"<td class=\"link\">" .
|
||||||
$cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'},
|
$cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'},
|
||||||
hash_base=>$hash, file_name=>$diff{'file'})},
|
hash_base=>$hash, file_name=>$diff{'file'})},
|
||||||
"blob") .
|
"blob");
|
||||||
"</td>\n";
|
if ($action == "commitdiff") {
|
||||||
|
# link to patch
|
||||||
|
$patchno++;
|
||||||
|
print " | " .
|
||||||
|
$cgi->a({-href => "#patch$patchno"}, "patch");
|
||||||
|
}
|
||||||
|
print "</td>\n";
|
||||||
|
|
||||||
} elsif ($diff{'status'} eq "D") { # deleted
|
} elsif ($diff{'status'} eq "D") { # deleted
|
||||||
my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
|
my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
|
||||||
@ -1515,8 +1522,14 @@ sub git_difftree_body {
|
|||||||
$cgi->a({-href => href(action=>"blob", hash=>$diff{'from_id'},
|
$cgi->a({-href => href(action=>"blob", hash=>$diff{'from_id'},
|
||||||
hash_base=>$parent, file_name=>$diff{'file'})},
|
hash_base=>$parent, file_name=>$diff{'file'})},
|
||||||
"blob") .
|
"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'})},
|
file_name=>$diff{'file'})},
|
||||||
"history") .
|
"history") .
|
||||||
"</td>\n";
|
"</td>\n";
|
||||||
@ -1556,6 +1569,12 @@ sub git_difftree_body {
|
|||||||
hash_base=>$hash, file_name=>$diff{'file'})},
|
hash_base=>$hash, file_name=>$diff{'file'})},
|
||||||
"blob");
|
"blob");
|
||||||
if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
|
if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
|
||||||
|
if ($action == "commitdiff") {
|
||||||
|
# link to patch
|
||||||
|
$patchno++;
|
||||||
|
print " | " .
|
||||||
|
$cgi->a({-href => "#patch$patchno"}, "patch");
|
||||||
|
} else {
|
||||||
print " | " .
|
print " | " .
|
||||||
$cgi->a({-href => href(action=>"blobdiff",
|
$cgi->a({-href => href(action=>"blobdiff",
|
||||||
hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
|
hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
|
||||||
@ -1563,6 +1582,7 @@ sub git_difftree_body {
|
|||||||
file_name=>$diff{'file'})},
|
file_name=>$diff{'file'})},
|
||||||
"diff");
|
"diff");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
print " | " .
|
print " | " .
|
||||||
$cgi->a({-href => href(action=>"history",
|
$cgi->a({-href => href(action=>"history",
|
||||||
hash_base=>$hash, file_name=>$diff{'file'})},
|
hash_base=>$hash, file_name=>$diff{'file'})},
|
||||||
@ -1591,6 +1611,12 @@ sub git_difftree_body {
|
|||||||
hash=>$diff{'to_id'}, file_name=>$diff{'to_file'})},
|
hash=>$diff{'to_id'}, file_name=>$diff{'to_file'})},
|
||||||
"blob");
|
"blob");
|
||||||
if ($diff{'to_id'} ne $diff{'from_id'}) {
|
if ($diff{'to_id'} ne $diff{'from_id'}) {
|
||||||
|
if ($action == "commitdiff") {
|
||||||
|
# link to patch
|
||||||
|
$patchno++;
|
||||||
|
print " | " .
|
||||||
|
$cgi->a({-href => "#patch$patchno"}, "patch");
|
||||||
|
} else {
|
||||||
print " | " .
|
print " | " .
|
||||||
$cgi->a({-href => href(action=>"blobdiff",
|
$cgi->a({-href => href(action=>"blobdiff",
|
||||||
hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
|
hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
|
||||||
@ -1598,6 +1624,7 @@ sub git_difftree_body {
|
|||||||
file_name=>$diff{'to_file'}, file_parent=>$diff{'from_file'})},
|
file_name=>$diff{'to_file'}, file_parent=>$diff{'from_file'})},
|
||||||
"diff");
|
"diff");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
} # we should not encounter Unmerged (U) or Unknown (X) status
|
} # we should not encounter Unmerged (U) or Unknown (X) status
|
||||||
@ -1629,7 +1656,7 @@ sub git_patchset_body {
|
|||||||
# first patch in patchset
|
# first patch in patchset
|
||||||
$patch_found = 1;
|
$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") {
|
if (ref($difftree->[$patch_idx]) eq "HASH") {
|
||||||
$diffinfo = $difftree->[$patch_idx];
|
$diffinfo = $difftree->[$patch_idx];
|
||||||
@ -2977,8 +3004,8 @@ TEXT
|
|||||||
|
|
||||||
# write patch
|
# write patch
|
||||||
if ($format eq 'html') {
|
if ($format eq 'html') {
|
||||||
#git_difftree_body(\@difftree, $hash, $hash_parent);
|
git_difftree_body(\@difftree, $hash, $hash_parent);
|
||||||
#print "<br/>\n";
|
print "<br/>\n";
|
||||||
|
|
||||||
git_patchset_body($fd, \@difftree, $hash, $hash_parent);
|
git_patchset_body($fd, \@difftree, $hash, $hash_parent);
|
||||||
close $fd;
|
close $fd;
|
||||||
|
Loading…
Reference in New Issue
Block a user