@matheusbsbs / matheus-bagliano / commits / fe87585e53
Fork 0

gitweb: Allow for pre-parsed difftree info in git_patchset_body

Preparation for converting git_blobdiff and git_blobdiff_plain to use git-diff-tree patch format to generate patches. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Aug 25, 2006 at 20:59 UTC fe87585e53860f1c89a088e91c08dd89b6702a74
1 file changed +30 -25
gitweb/gitweb.perl
+30 -25
@@ -1624,7 +1624,7 @@ sub git_patchset_body {
1624 my $patch_idx = 0;
1625 my $in_header = 0;
1626 my $patch_found = 0;
1627 - my %diffinfo;
1627 + my $diffinfo;
1628
1629 print "<div class=\"patchset\">\n";
1630
@@ -1643,54 +1643,59 @@ sub git_patchset_body {
1643 }
1644 print "<div class=\"patch\">\n";
1645
1646 - %diffinfo = parse_difftree_raw_line($difftree->[$patch_idx++]);
1646 + if (ref($difftree->[$patch_idx]) eq "HASH") {
1647 + $diffinfo = $difftree->[$patch_idx];
1648 + } else {
1649 + $diffinfo = parse_difftree_raw_line($difftree->[$patch_idx]);
1650 + }
1651 + $patch_idx++;
1652
1653 # for now, no extended header, hence we skip empty patches
1654 # companion to next LINE if $in_header;
1650 - if ($diffinfo{'from_id'} eq $diffinfo{'to_id'}) { # no change
1655 + if ($diffinfo->{'from_id'} eq $diffinfo->{'to_id'}) { # no change
1656 $in_header = 1;
1657 next LINE;
1658 }
1659
1655 - if ($diffinfo{'status'} eq "A") { # added
1656 - print "<div class=\"diff_info\">" . file_type($diffinfo{'to_mode'}) . ":" .
1660 + if ($diffinfo->{'status'} eq "A") { # added
1661 + print "<div class=\"diff_info\">" . file_type($diffinfo->{'to_mode'}) . ":" .
1662 $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
1658 - hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'file'})},
1659 - $diffinfo{'to_id'}) . "(new)" .
1663 + hash=>$diffinfo->{'to_id'}, file_name=>$diffinfo->{'file'})},
1664 + $diffinfo->{'to_id'}) . "(new)" .
1665 "</div>\n"; # class="diff_info"
1666
1662 - } elsif ($diffinfo{'status'} eq "D") { # deleted
1663 - print "<div class=\"diff_info\">" . file_type($diffinfo{'from_mode'}) . ":" .
1667 + } elsif ($diffinfo->{'status'} eq "D") { # deleted
1668 + print "<div class=\"diff_info\">" . file_type($diffinfo->{'from_mode'}) . ":" .
1669 $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
1665 - hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'file'})},
1666 - $diffinfo{'from_id'}) . "(deleted)" .
1670 + hash=>$diffinfo->{'from_id'}, file_name=>$diffinfo->{'file'})},
1671 + $diffinfo->{'from_id'}) . "(deleted)" .
1672 "</div>\n"; # class="diff_info"
1673
1669 - } elsif ($diffinfo{'status'} eq "R" || # renamed
1670 - $diffinfo{'status'} eq "C") { # copied
1674 + } elsif ($diffinfo->{'status'} eq "R" || # renamed
1675 + $diffinfo->{'status'} eq "C") { # copied
1676 print "<div class=\"diff_info\">" .
1672 - file_type($diffinfo{'from_mode'}) . ":" .
1677 + file_type($diffinfo->{'from_mode'}) . ":" .
1678 $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
1674 - hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'from_file'})},
1675 - $diffinfo{'from_id'}) .
1679 + hash=>$diffinfo->{'from_id'}, file_name=>$diffinfo->{'from_file'})},
1680 + $diffinfo->{'from_id'}) .
1681 " -> " .
1677 - file_type($diffinfo{'to_mode'}) . ":" .
1682 + file_type($diffinfo->{'to_mode'}) . ":" .
1683 $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
1679 - hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'to_file'})},
1680 - $diffinfo{'to_id'});
1684 + hash=>$diffinfo->{'to_id'}, file_name=>$diffinfo->{'to_file'})},
1685 + $diffinfo->{'to_id'});
1686 print "</div>\n"; # class="diff_info"
1687
1688 } else { # modified, mode changed, ...
1689 print "<div class=\"diff_info\">" .
1685 - file_type($diffinfo{'from_mode'}) . ":" .
1690 + file_type($diffinfo->{'from_mode'}) . ":" .
1691 $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
1687 - hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'file'})},
1688 - $diffinfo{'from_id'}) .
1692 + hash=>$diffinfo->{'from_id'}, file_name=>$diffinfo->{'file'})},
1693 + $diffinfo->{'from_id'}) .
1694 " -> " .
1690 - file_type($diffinfo{'to_mode'}) . ":" .
1695 + file_type($diffinfo->{'to_mode'}) . ":" .
1696 $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
1692 - hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'file'})},
1693 - $diffinfo{'to_id'});
1697 + hash=>$diffinfo->{'to_id'}, file_name=>$diffinfo->{'file'})},
1698 + $diffinfo->{'to_id'});
1699 print "</div>\n"; # class="diff_info"
1700 }
1701