X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FGit%2FObject%2FCommit.pm;h=7536a665f5f43bb271241d1313c27cf845746264;hb=6bff0cc106a6169e52e58d78d6e2ea48bfa3ead1;hp=ef36f05a6665d98963ad3b8c5ddb0fa190718ba4;hpb=799c61908612b5fee0c4c5101f3f2bc0140b0025;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/Git/Object/Commit.pm b/lib/Gitalist/Git/Object/Commit.pm index ef36f05..7536a66 100644 --- a/lib/Gitalist/Git/Object/Commit.pm +++ b/lib/Gitalist/Git/Object/Commit.pm @@ -49,7 +49,7 @@ class Gitalist::Git::Object::Commit method diff ( Maybe[Bool] :$patch?, Maybe[NonEmptySimpleStr] :$parent?, - Maybe[NonEmptySimpleStr] :$file? + Maybe[NonEmptySimpleStr] :$filename? ) { $parent = $parent ? $parent @@ -57,13 +57,19 @@ class Gitalist::Git::Object::Commit ? $self->parent_sha1 : '-c'; my @etc = ( - ( $file ? ('--', $file) : () ), + ( $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 && $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. @@ -105,7 +111,7 @@ class Gitalist::Git::Object::Commit $line{sha1} = $line{sha1dst}; $line{is_new} = $line{sha1src} =~ /^0+$/ if $line{sha1src}; - @line{qw/status sim/} = $line{status} =~ /(R)(\d+)/ + @line{qw/status sim/} = $line{status} =~ /(R)0*(\d+)/ if $line{status} =~ /^R/; push @ret, \%line; } @@ -128,7 +134,7 @@ class Gitalist::Git::Object::Commit next; } - if (/^index (\w+)\.\.(\w+) (\d+)$/) { + if (/^index (\w+)\.\.(\w+)(?: (\d+))?$/) { @{$ret[-1]}{qw(index src dst mode)} = ($_, $1, $2, $3); next }