less itself isn't capable of doing syntax highlighting, according to this thread.
However, git diff nicely shows colored output in less, its default pager. When I redirect the output of git diff into a file, no color escape sequences are visible.
Does git diff know where it's being sent, and formats the output accordingly? How would one do that?
I just noticed that git colors the diff output (e.g. git diff), however, it doesn't know how to syntax highlighting in general. e.g.
git show 415fec6:log.tex
doesn't enable any TeX-like syntax.
Reading the git sources, I found the following hints
in diff.h:
int use_color;
I was previously referring to syntax highlighting, but that was not correct. What I mean is output coloring, see e.g.

git diff --color=always | less -r(orless -Rfor ANSI). BTW: for other commands that don't paginate by default (git diffdoes) you can switch it on:git -p some_git_command