From: Dan Brook Date: Sat, 19 Jun 2010 20:27:17 +0000 (+0100) Subject: Handle merges in the diff view. X-Git-Tag: 0.002002~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FGitalist.git;a=commitdiff_plain;h=9c9f54f07d50f0999085da94be9babc678f408f2 Handle merges in the diff view. Now Gitalist::Git::Object::Commit::diff supports returning something useful for merge commits. It now shows the difference between the two parents of the commit, not sure if it covers octopus merges. Also gets you something meaningful in the ///diff view finally. --- diff --git a/lib/Gitalist/Git/Object/Commit.pm b/lib/Gitalist/Git/Object/Commit.pm index ee3ba13..5f0c7de 100644 --- a/lib/Gitalist/Git/Object/Commit.pm +++ b/lib/Gitalist/Git/Object/Commit.pm @@ -60,10 +60,16 @@ class Gitalist::Git::Object::Commit ( $filename ? ('--', $filename) : () ), ); + # If we're not comparing against something and we have multiple + # parents then it's a merge commit so show what was merged. + my $sha1 = $parent eq '-c' && @{[$self->parents]} > 1 + ? sprintf("%s^1..%s^2", ($self->sha1) x 2) + : $self->sha1; + my @out = $self->_raw_diff( ( $patch ? '--patch-with-raw' : () ), ( $parent ? $parent : () ), - $self->sha1, @etc, + $sha1, @etc, ); # XXX Yes, there is much wrongness having _parse_diff_tree be destructive.