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

Re: [PATCH v4 2/2] gitweb: use highlight's shebang detection

From
Jakub Narębski <jnareb@gmail.com>
Date
Sep 25, 2016, 18:04 UTC
Message-ID
<c35fc760-ae64-5df3-5985-7eecd06d937f@gmail.com>
In-Reply-To
<20160924223258.9449-2-ian@iankelling.org>
W dniu 25.09.2016 o 00:32, Ian Kelling pisze:
Show 21 quoted lines
> The "highlight" binary can, in some cases, determine the language type
> by the means of file contents, for example the shebang in the first line
> for some scripting languages.  Make use of this autodetection for files
> which syntax is not known by gitweb.  In that case, pass the blob
> contents to "highlight --force"; the parameter is needed to make it
> always generate HTML output (which includes HTML-escaping).
> 
> Although we now run highlight on files which do not end up highlighted,
> performance is virtually unaffected because when we call highlight, it
> is used for escaping HTML.  In the case that highlight is used, gitweb
> calls sanitize() instead of esc_html(), and the latter is significantly
> slower (it does more, being roughly a superset of sanitize()).  Simple
> benchmark comparing performance of 'blob' view of files without syntax
> highlighting in gitweb before and after this change indicates ±1%
> difference in request time for all file types.  Benchmark was performed
> on local instance on Debian, using Apache/2.4.23 web server and CGI.
> 
> Document the feature and improve syntax highlight documentation, add
> test to ensure gitweb doesn't crash when language detection is used.
> 
> Signed-off-by: Ian Kelling <ian@iankelling.org>
For what it is worth it:
Acked-by: Jakub Narębski <jnareb@gmail.com>
(but unfortunately *not* tested by).
Show 10 quoted lines
> ---
> 
> Notes:
>     The only change from v3 is the commit message as suggested by Jakub
>     Narębski
> 
>  Documentation/gitweb.conf.txt          | 21 ++++++++++++++-------
>  gitweb/gitweb.perl                     | 10 +++++-----
>  t/t9500-gitweb-standalone-no-errors.sh |  8 ++++++++
>  3 files changed, 27 insertions(+), 12 deletions(-)
Previous: Ian KellingNext: Ian Kelling
Message 19 of 23 in “gitweb: use highlight's shebang detection”
  1. gitweb: use highlight's shebang detectionIan Kelling, Sep 6, 2016
  2. Jakub NarębskiSep 20, 2016
  3. Junio C HamanoSep 21, 2016
  4. Jakub NarębskiSep 21, 2016
  5. Ian KellingSep 21, 2016
  6. gitweb: use highlight's shebang detectionIan Kelling, Sep 21, 2016
  7. Ian KellingSep 21, 2016
  8. Jakub NarębskiSep 22, 2016
  9. Ian KellingSep 23, 2016
  10. 1/2 gitweb: remove unused function parameterIan Kelling, Sep 23, 2016
  11. 2/2 gitweb: use highlight's shebang detectionIan Kelling, Sep 23, 2016
  12. Jakub NarębskiSep 23, 2016
  13. Jakub NarębskiSep 24, 2016
  14. Junio C HamanoSep 24, 2016
  15. Ian KellingSep 24, 2016
  16. Ian KellingSep 24, 2016
  17. 1/2 gitweb: remove unused guess_file_syntax() parameterIan Kelling, Sep 24, 2016
  18. 2/2 gitweb: use highlight's shebang detectionIan Kelling, Sep 24, 2016
  19. Jakub NarębskiSep 25, 2016
  20. Ian KellingSep 28, 2016
  21. Jakub NarębskiSep 25, 2016
  22. Jakub NarębskiSep 23, 2016
  23. Junio C HamanoSep 23, 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.