]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
use git show to get the diff
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 12 Mar 2008 18:44:20 +0000 (14:44 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 12 Mar 2008 18:44:20 +0000 (14:44 -0400)
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.

IkiWiki/Rcs/git.pm

index 9f65e86aa37e3a63738ce3aacf0a1f9496b57daa..9306a513eb01b0bb6e013e7aad5523d341cb195b 100644 (file)
@@ -414,7 +414,16 @@ sub rcs_recentchanges ($) { #{{{
 sub rcs_diff ($) { #{{{
        my $rev=shift;
        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 ($) { #{{{