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

gitweb: Show combined diff for merge commits in 'commitdiff' view

When 'commitdiff' action is requested without 'hp' (hash parent) parameter, and commit given by 'h' (hash) parameter is merge commit, show merge as combined diff. Earlier for merge commits without 'hp' parameter diff to first parent was shown. Note that in compact combined (--cc) format 'uninteresting' hunks omission mechanism can make that there is no patch corresponding to line in raw format (difftree) output. That is why (at least for now) we use --combined and not --cc format for showing commitdiff for merge commits. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed May 7, 2007 at 01:10 UTC fb1dde4a908ddcfaa884f67734a60dc6bd639b59
1 file changed +7 -5
gitweb/gitweb.perl
+7 -5
@@ -4391,8 +4391,10 @@ sub git_commitdiff {
4391 }
4392 }
4393
4394 + my $hash_parent_param = $hash_parent;
4395 if (!defined $hash_parent) {
4395 - $hash_parent = $co{'parent'} || '--root';
4396 + $hash_parent_param =
4397 + @{$co{'parents'}} > 1 ? '-c' : $co{'parent'} || '--root';
4398 }
4399
4400 # read commitdiff
@@ -4401,7 +4403,7 @@ sub git_commitdiff {
4403 if ($format eq 'html') {
4404 open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
4405 "--no-commit-id", "--patch-with-raw", "--full-index",
4404 - $hash_parent, $hash, "--"
4406 + $hash_parent_param, $hash, "--"
4407 or die_error(undef, "Open git-diff-tree failed");
4408
4409 while (my $line = <$fd>) {
@@ -4413,7 +4415,7 @@ sub git_commitdiff {
4415
4416 } elsif ($format eq 'plain') {
4417 open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
4416 - '-p', $hash_parent, $hash, "--"
4418 + '-p', $hash_parent_param, $hash, "--"
4419 or die_error(undef, "Open git-diff-tree failed");
4420
4421 } else {
@@ -4469,10 +4471,10 @@ TEXT
4471
4472 # write patch
4473 if ($format eq 'html') {
4472 - git_difftree_body(\@difftree, $hash, $hash_parent);
4474 + git_difftree_body(\@difftree, $hash, $hash_parent || @{$co{'parents'}});
4475 print "<br/>\n";
4476
4475 - git_patchset_body($fd, \@difftree, $hash, $hash_parent);
4477 + git_patchset_body($fd, \@difftree, $hash, $hash_parent || @{$co{'parents'}});
4478 close $fd;
4479 print "</div>\n"; # class="page_body"
4480 git_footer_html();