+sub git_patchset_body {
+ my ($patchset, $difftree, $hash, $hash_parent) = @_;
+
+ my $patch_idx = 0;
+ my $in_header = 0;
+ my $patch_found = 0;
+ my %diffinfo;
+
+ print "<div class=\"patchset\">\n";
+
+ LINE: foreach my $patch_line (@$patchset) {
+
+ if ($patch_line =~ m/^diff /) { # "git diff" header
+ # beginning of patch (in patchset)
+ if ($patch_found) {
+ # close previous patch
+ print "</div>\n"; # class="patch"
+ } else {
+ # first patch in patchset
+ $patch_found = 1;
+ }
+ print "<div class=\"patch\">\n";
+
+ %diffinfo = parse_difftree_raw_line($difftree->[$patch_idx++]);
+
+ # for now, no extended header, hence we skip empty patches
+ # companion to next LINE if $in_header;
+ if ($diffinfo{'from_id'} eq $diffinfo{'to_id'}) { # no change
+ $in_header = 1;
+ next LINE;
+ }
+
+ if ($diffinfo{'status'} eq "A") { # added
+ print "<div class=\"diff_info\">" . file_type($diffinfo{'to_mode'}) . ":" .
+ $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
+ hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'file'})},
+ $diffinfo{'to_id'}) . "(new)" .
+ "</div>\n"; # class="diff_info"
+
+ } elsif ($diffinfo{'status'} eq "D") { # deleted
+ print "<div class=\"diff_info\">" . file_type($diffinfo{'from_mode'}) . ":" .
+ $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
+ hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'file'})},
+ $diffinfo{'from_id'}) . "(deleted)" .
+ "</div>\n"; # class="diff_info"
+
+ } elsif ($diffinfo{'status'} eq "R" || # renamed
+ $diffinfo{'status'} eq "C") { # copied
+ print "<div class=\"diff_info\">" .
+ file_type($diffinfo{'from_mode'}) . ":" .
+ $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
+ hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'from_file'})},
+ $diffinfo{'from_id'}) .
+ " -> " .
+ file_type($diffinfo{'to_mode'}) . ":" .
+ $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
+ hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'to_file'})},
+ $diffinfo{'to_id'});
+ print "</div>\n"; # class="diff_info"
+
+ } else { # modified, mode changed, ...
+ print "<div class=\"diff_info\">" .
+ file_type($diffinfo{'from_mode'}) . ":" .
+ $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
+ hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'file'})},
+ $diffinfo{'from_id'}) .
+ " -> " .
+ file_type($diffinfo{'to_mode'}) . ":" .
+ $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
+ hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'file'})},
+ $diffinfo{'to_id'});
+ print "</div>\n"; # class="diff_info"
+ }
+
+ #print "<div class=\"diff extended_header\">\n";
+ $in_header = 1;
+ next LINE;
+ } # start of patch in patchset
+
+
+ if ($in_header && $patch_line =~ m/^---/) {
+ #print "</div>\n"
+ $in_header = 0;
+ }
+ next LINE if $in_header;
+
+ print format_diff_line($patch_line);
+ }
+ print "</div>\n" if $patch_found; # class="patch"
+
+ print "</div>\n"; # class="patchset"
+}
+
+# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
+