git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* The gitweb author initials feature from a36817b doesn't work with i18n names
@ 2013-08-29 14:26 Ævar Arnfjörð Bjarmason
  2013-08-29 14:44 ` Jakub Narębski
  2013-08-29 16:39 ` Simon Ruderich
  0 siblings, 2 replies; 13+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2013-08-29 14:26 UTC (permalink / raw)
  To: Jakub Narębski; +Cc: Git Mailing List

The @author_initials feature Jakub added in a36817b claims to use a
i18n regexp (/\b([[:upper:]])\B/g), but in Perl this doesn't actually
do anything unless the string being matched against has the UTF8 flag.

So as a result it abbreviates me to "AB" not "ÆAB". Here's something
that demonstrates the issue:

$ cat author-initials.pl
#!/usr/bin/env perl
use strict;
use warnings;

#binmode STDOUT, ':utf8';
open my $fd, "-|", "git", "blame", "--incremental", "--", "Makefile"
or die "Can't open: $!";
#binmode $fd, ":utf8";
while (my $line = <$fd>) {
        next unless my ($author) = $line =~ /^author (.*)/;
        my @author_initials = ($author =~ /\b([[:upper:]])\B/g);
        printf "%s (%s)\n",  join("", @author_initials), $author;
}

With those two binmode commands commented out:

$ perl author-initials.pl |sort|uniq -c|sort -nr|head -n 5
     99 JH (Junio C Hamano)
     35 JN (Jonathan Nieder)
     35 JK (Jeff King)
     20 JS (Johannes Schindelin)
     16 AB (Ævar Arnfjörð Bjarmason)

And uncommented:

$ perl author-initials.pl |sort|uniq -c|sort -nr|head -n 5
     99 JH (Junio C Hamano)
     35 JN (Jonathan Nieder)
     35 JK (Jeff King)
     20 JS (Johannes Schindelin)
     16 ÆAB (Ævar Arnfjörð Bjarmason)

Jakub, do you see a reason not to just apply this:

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f429f75..29b3fb5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -6631,6 +6631,7 @@ sub git_blame_common {
                        $hash_base, '--', $file_name
                        or die_error(500, "Open git-blame --porcelain failed");
        }
+       binmode $fd, ":utf8";

        # incremental blame data returns early
        if ($format eq 'data') {

I haven't gotten an env where I can test gitweb running, but that
looks like it should work to me.

^ permalink raw reply related	[flat|nested] 13+ messages in thread
* Re: [PATCH] gitweb: Fix the author initials in blame for non-ASCII names
@ 2014-03-17  9:21 Kicer Jiao
  2014-03-17  9:34 ` Kicer Jiao
  0 siblings, 1 reply; 13+ messages in thread
From: Kicer Jiao @ 2014-03-17  9:21 UTC (permalink / raw)
  To: gitster; +Cc: git

Dear all,

I have a git-project which source code use gbk encoding. When use
gitweb blame view, it will report an error then stop parse:
>    Malformed UTF-8 character (fatal) at /usr/share/gitweb/gitweb.cgi line 1595, &lt;$fd&gt; line 45.

After apply this patch, blame view of gbk source file will back to normally.
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 79057b7..e6fdcfe 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -6704,7 +6704,6 @@ sub git_blame_common {
                        $hash_base, '--', $file_name
                        or die_error(500, "Open git-blame --porcelain failed");
        }
-       binmode $fd, ':utf8';

        # incremental blame data returns early
        if ($format eq 'data') {

When I search the git.git log, this commit add the "binmode ..." line,
maybe should recheck this commit? Thanks.
fd87004e51df835e5833bfe1bff3ad0137d42227  "gitweb: Fix the author
initials in blame for non-ASCII names"


BR,
2014-03-17

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-03-17  9:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29 14:26 The gitweb author initials feature from a36817b doesn't work with i18n names Ævar Arnfjörð Bjarmason
2013-08-29 14:44 ` Jakub Narębski
2013-08-29 16:39 ` Simon Ruderich
2013-08-30  8:37   ` [PATCH] gitweb: Fix the author initials in blame for non-ASCII names Ævar Arnfjörð Bjarmason
2013-08-30 18:05     ` Junio C Hamano
2013-08-30 18:08       ` Jakub Narębski
2013-08-30 18:13       ` Junio C Hamano
2013-08-30 18:31         ` Simon Ruderich
2013-08-30 21:39         ` Kyle J. McKay
2013-08-31 16:42           ` Jakub Narębski
2013-08-31 16:29         ` Ævar Arnfjörð Bjarmason
  -- strict thread matches above, loose matches on Subject: below --
2014-03-17  9:21 Kicer Jiao
2014-03-17  9:34 ` Kicer Jiao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).