Skip to content

Commit

Permalink
gitweb: Do not show difftree for merges in "commit" view
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Dec 16, 2006
1 parent bfe2191 commit 549ab4a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -3572,14 +3572,19 @@ sub git_commit {
my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});

my $parent = $co{'parent'};
my $parents = $co{'parents'};
if (!defined $parent) {
$parent = "--root";
}
open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
@diff_opts, $parent, $hash, "--"
or die_error(undef, "Open git-diff-tree failed");
my @difftree = map { chomp; $_ } <$fd>;
close $fd or die_error(undef, "Reading git-diff-tree failed");
my @difftree;
if (@$parents <= 1) {
# difftree output is not printed for merges
open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
@diff_opts, $parent, $hash, "--"
or die_error(undef, "Open git-diff-tree failed");
@difftree = map { chomp; $_ } <$fd>;
close $fd or die_error(undef, "Reading git-diff-tree failed");
}

# non-textual hash id's can be cached
my $expires;
Expand Down Expand Up @@ -3641,7 +3646,7 @@ sub git_commit {
}
print "</td>" .
"</tr>\n";
my $parents = $co{'parents'};

foreach my $par (@$parents) {
print "<tr>" .
"<td>parent</td>" .
Expand All @@ -3663,7 +3668,10 @@ sub git_commit {
git_print_log($co{'comment'});
print "</div>\n";

git_difftree_body(\@difftree, $hash, $parent);
if (@$parents <= 1) {
# do not output difftree/whatchanged for merges
git_difftree_body(\@difftree, $hash, $parent);
}

git_footer_html();
}
Expand Down

0 comments on commit 549ab4a

Please sign in to comment.