@matheusbsbs / matheus-bagliano / commits / 549ab4a307
Fork 0

gitweb: Do not show difftree for merges in "commit" view

Do not show difftree against first parent for merges (commits with more than one parent) in "commit" view, because it usually is misleading. git-show and git-whatchanged doesn't show diff for merges either. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Dec 15, 2006 at 17:53 UTC 549ab4a30703012ff3a12b5455d319216805a8db
1 file changed +15 -7
gitweb/gitweb.perl
+15 -7
@@ -3572,14 +3572,19 @@ sub git_commit {
3572 my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
3573
3574 my $parent = $co{'parent'};
3575 + my $parents = $co{'parents'};
3576 if (!defined $parent) {
3577 $parent = "--root";
3578 }
3578 - open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
3579 - @diff_opts, $parent, $hash, "--"
3580 - or die_error(undef, "Open git-diff-tree failed");
3581 - my @difftree = map { chomp; $_ } <$fd>;
3582 - close $fd or die_error(undef, "Reading git-diff-tree failed");
3579 + my @difftree;
3580 + if (@$parents <= 1) {
3581 + # difftree output is not printed for merges
3582 + open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
3583 + @diff_opts, $parent, $hash, "--"
3584 + or die_error(undef, "Open git-diff-tree failed");
3585 + @difftree = map { chomp; $_ } <$fd>;
3586 + close $fd or die_error(undef, "Reading git-diff-tree failed");
3587 + }
3588
3589 # non-textual hash id's can be cached
3590 my $expires;
@@ -3641,7 +3646,7 @@ sub git_commit {
3646 }
3647 print "</td>" .
3648 "</tr>\n";
3644 - my $parents = $co{'parents'};
3649 +
3650 foreach my $par (@$parents) {
3651 print "<tr>" .
3652 "<td>parent</td>" .
@@ -3663,7 +3668,10 @@ sub git_commit {
3668 git_print_log($co{'comment'});
3669 print "</div>\n";
3670
3666 - git_difftree_body(\@difftree, $hash, $parent);
3671 + if (@$parents <= 1) {
3672 + # do not output difftree/whatchanged for merges
3673 + git_difftree_body(\@difftree, $hash, $parent);
3674 + }
3675
3676 git_footer_html();
3677 }