git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: apply fallback encoding before highlight

From
Jakub Narębski <jnareb@gmail.com>
Date
May 2, 2016, 18:12 UTC
Message-ID
<CANQwDwfZPoNd7OTpSkEmf4amV0hh8kiuk3omwLCS0O=MZ1DB=A@mail.gmail.com>
In-Reply-To
<xmqqbn4ouz7u.fsf@gitster.mtv.corp.google.com>
On Mon, May 2, 2016 at 7:49 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 11 quoted lines
> Shin Kojima <shin@kojima.org> writes:
>
>> This patch prepare git blob objects to be encoded into UTF-8 before
>> highlighting in the manner of `to_utf8` subroutine.
>> ---
>
> The single liner Perl invoked from the script felt a bit too dense
> to my taste but other than that I have no complaints to what the
> patched code does.
>
> Jakub, does it look good to you, too?

Yes, it looks all right to me. $^X is current Perl. -CO means that the output is utf8 (for `highlight` command), -p means read all lines and print them (it could be replaced by "print" command in one-liner), -s is here to pass $fallback_encoding as $fe (it could be replaced, but it would require some fiddling with quoting $s), -e '...' means execute one line.

Show 22 quoted lines
> Please sign-off your patch (see Documentation/SubmittingPatches).
>
> Thanks.
>
>
>>  gitweb/gitweb.perl | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
>> index 05d7910..2fddf75 100755
>> --- a/gitweb/gitweb.perl
>> +++ b/gitweb/gitweb.perl
>> @@ -3935,6 +3935,9 @@ sub run_highlighter {
>>
>>       close $fd;
>>       open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
>> +               quote_command($^X, '-CO', '-MEncode=decode,FB_DEFAULT', '-pse',
>> +                 '$_ = decode($fe, $_, FB_DEFAULT) if !utf8::decode($_);',
>> +                 '--', "-fe=$fallback_encoding")." | ".
>>                 quote_command($highlight_bin).
>>                 " --replace-tabs=8 --fragment --syntax $syntax |"
>>               or die_error(500, "Couldn't open file or run syntax highlighter");
-- 
Jakub Narebski
Previous: Junio C HamanoNext: Shin Kojima
Message 3 of 8 in “gitweb: apply fallback encoding before highlight”
  1. gitweb: apply fallback encoding before highlightShin Kojima, Apr 20, 2016
  2. Junio C HamanoMay 2, 2016
  3. Jakub NarębskiMay 2, 2016
  4. gitweb: apply fallback encoding before highlightShin Kojima, May 3, 2016
  5. Junio C HamanoMay 3, 2016
  6. Shin KojimaMay 4, 2016
  7. Junio C HamanoMay 4, 2016
  8. Shin KojimaMay 5, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.