]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/git.pm
On some systems the commit message gets quoted properly already. Don't
[ikiwiki.git] / IkiWiki / Plugin / git.pm
index 12f3a74cb7a11178b29fae3300f9e84db76c07b7..68b114a7328332a54d8e66426bd09dc1eec0b030 100644 (file)
@@ -136,14 +136,16 @@ sub safe_git (&@) {
        }
        # In parent.
 
+       # git output is probably utf-8 encoded, but may contain
+       # other encodings or invalidly encoded stuff. So do not rely
+       # on the normal utf-8 IO layer, decode it by hand.
+       binmode($OUT);
+
        my @lines;
        while (<$OUT>) {
+               $_=decode_utf8($_, 0);
+
                chomp;
-               
-               # check for invalid utf-8, and toss it back to avoid crashes
-               if (! utf8::valid($_)) {
-                       $_=encode_utf8($_);
-               }
 
                push @lines, $_;
        }
@@ -592,8 +594,8 @@ sub rcs_getctime ($) {
        # Remove srcdir prefix
        $file =~ s/^\Q$config{srcdir}\E\/?//;
 
-       my $sha1  = git_sha1($file);
-       my $ci    = git_commit_info($sha1, 1);
+       my @sha1s = run_or_non('git', 'rev-list', 'HEAD', '--', $file);
+       my $ci    = git_commit_info($sha1s[$#sha1s], 1);
        my $ctime = $ci->{'author_epoch'};
        debug("ctime for '$file': ". localtime($ctime));