summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-09-25 18:26:42 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-09-25 18:26:42 -0400
commit965f7310fec535d17e04464019de4ca75fa0afec (patch)
treebea5042f5c6511f23580e657daee516b878f2007 /IkiWiki/Plugin
parenta4215312d0564e335b16ec6f02e90907426e3771 (diff)
git: Fix handling of utf-8 filenames in recentchanges.
Seems that the problem is that once the \nnn coming from git is converted to a single character, decode_utf8 decides that this is a standalone character, and not part of a multibyte utf-8 sequence, and so does nothing. I tried playing with the utf-8 flag, but that didn't work. Instead, use decode("utf8"), which doesn't have the same qualms, and successfully decodes the octets into a utf-8 character. Rant: Think for a minute about fact that any and every program that parses git-log, or git-show, etc output to figure out what files were in a commit needs to contain this snippet of code, to convert from git-log's wacky output to a regular character set: if ($file =~ m/^"(.*)"$/) { ($file=$1) =~ s/\\([0-7]{1,3})/chr(oct($1))/eg; } (And it's only that "simple" if you don't care about filenames with embedded \n or \t or other control characters.) Does that strike anyone else as putting the parsing and conversion in the wrong place (ie, in gitweb, ikiwiki, etc, etc)? Doesn't anyone who actually uses git with utf-8 filenames get a bit pissed off at seeing \xxx\xxx instead of the utf-8 in git-commit and other output?
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/git.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm
index 08ee4cb63..14b0ab285 100644
--- a/IkiWiki/Plugin/git.pm
+++ b/IkiWiki/Plugin/git.pm
@@ -308,13 +308,16 @@ sub parse_diff_tree ($@) { #{{{
my $sha1_to = shift(@tmp);
my $status = shift(@tmp);
+ # git does not output utf-8 filenames, but instead
+ # double-quotes them with the utf-8 characters
+ # escaped as \nnn\nnn.
if ($file =~ m/^"(.*)"$/) {
($file=$1) =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
}
$file =~ s/^\Q$prefix\E//;
if (length $file) {
push @{ $ci{'details'} }, {
- 'file' => decode_utf8($file),
+ 'file' => decode("utf8", $file),
'sha1_from' => $sha1_from[0],
'sha1_to' => $sha1_to,
};