From 7bd0d536442493a8898981a8a784bf16126085c5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 9 Mar 2009 14:01:40 -0400 Subject: git: Fix utf-8 encoding of author names. I guess what's happening here is that since the name is passed to git via an environment variable, perl's normal utf-8 IO layer stuff doesn't work. So we have to explicitly decode the string from perl's internal representation into utf-8. --- IkiWiki/Plugin/git.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin/git.pm') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 042c69f5a..12f3a74cb 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -447,7 +447,7 @@ sub rcs_commit_staged ($$$) { # Set the commit author and email to the web committer. my %env=%ENV; if (defined $user || defined $ipaddr) { - my $u=defined $user ? $user : $ipaddr; + my $u=encode_utf8(defined $user ? $user : $ipaddr); $ENV{GIT_AUTHOR_NAME}=$u; $ENV{GIT_AUTHOR_EMAIL}="$u\@web"; } -- cgit v1.2.3 From 4ac0b2953131d7a53562ab8918c8e5a49952d8ac Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 9 Mar 2009 14:18:55 -0400 Subject: git: Manually decode git output from utf-8, avoids warning messages on invalidly encoded output. --- IkiWiki/Plugin/git.pm | 12 +++++++----- debian/changelog | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Plugin/git.pm') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 12f3a74cb..b386ab71b 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -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, $_; } diff --git a/debian/changelog b/debian/changelog index a7e7544c6..77b5d9fa6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ ikiwiki (3.08) UNRELEASED; urgency=low * git: Fix utf-8 encoding of author names. + * git: Manually decode git output from utf-8, avoids + warning messages on invalidly encoded output. -- Joey Hess Mon, 09 Mar 2009 14:00:21 -0400 -- cgit v1.2.3 From a2c0423e541006f5d1c0c99f4bb07aadfb0cc733 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 20 Mar 2009 16:32:37 -0400 Subject: fix rcs_getctime to return first, not last, change time This was being buggy and returning the file's last change time, not its creation time. (I checked all the others (except tla) and they're ok.) --- IkiWiki/Plugin/git.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/git.pm') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index b386ab71b..68b114a73 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -594,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)); -- cgit v1.2.3