summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorIan Kelling <ian@iankelling.org>2016-09-24 22:32:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-25 23:39:11 (GMT)
commit779a20663230ab068dcbc3c5bc53d44a5e37b0aa (patch)
tree6c029f873285961577ee37bbd2440ff7c763bd49 /builtin
parentc151aa3b58c952899531aa52e64d76b50fb52e62 (diff)
downloadgit-779a20663230ab068dcbc3c5bc53d44a5e37b0aa.zip
git-779a20663230ab068dcbc3c5bc53d44a5e37b0aa.tar.gz
git-779a20663230ab068dcbc3c5bc53d44a5e37b0aa.tar.bz2
gitweb: use highlight's shebang detection
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> Acked-by: Jakub Narębski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
0 files changed, 0 insertions, 0 deletions