use git show to get the diff

If a diff of the firsst commit in a git repo was requested, it would fail and
print to stderr since first^ isn't valid. Using git show will always work.
master
Joey Hess 2008-03-12 14:44:20 -04:00
parent 20f1365ce1
commit 3dc979470e
1 changed files with 10 additions and 1 deletions

View File

@ -414,7 +414,16 @@ sub rcs_recentchanges ($) { #{{{
sub rcs_diff ($) { #{{{ sub rcs_diff ($) { #{{{
my $rev=shift; my $rev=shift;
my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint
return join("\n", run_or_non("git", "diff", "$sha1^", $sha1)); my $ret;
foreach my $line (run_or_non("git", "show", $sha1)) {
if (defined $ret) {
$ret.=$line."\n";
}
elsif ($line=~/^diff --git/) {
$ret=$line."\n";
}
}
return $ret;
} #}}} } #}}}
sub rcs_getctime ($) { #{{{ sub rcs_getctime ($) { #{{{