1

I'm unable to get syntax highlighting working with gitweb. I've been stuck on this for several days now and appreciate any help. I've done a lot of research and tried many things but nothing seems to work. I am able to view gitweb just with no syntax highlighting.

# cat /etc/centos-release
  CentOS release 6.4 (Final)

# rpm -qa | grep highlight
  highlight-3.8-1.el6.x86_64

# rpm -qa | grep gitweb
  gitweb-1.7.1-3.el6_4.1.noarch

# rpm -qa | grep git
  git-1.7.1-3.el6_4.1.x86_64

/etc/httpd/conf.d/git.conf

Alias /git /var/www/git

# Suexec setup
SuexecUserGroup gitolite gitolite


# Set up appropriate GIT environments
SetEnv GIT_PROJECT_ROOT /var/lib/gitolite/repositories
SetEnv GIT_HTTP_EXPORT_ALL

# Set up appropriate gitolite environment
SetEnv GITOLITE_HTTP_HOME /var/lib/gitolite

# To serve gitweb at the same url, use a ScriptAliasMatch to
# only those URLs that git http-backend can handle, and
# forward the rest to gitweb:
ScriptAliasMatch \
    "(?x)^/(.*/(HEAD | \
                    info/refs | \
                    objects/(info/[^/]+ | \
                             [0-9a-f]{2}/[0-9a-f]{38} | \
                             pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                    git-(upload|receive)-pack))$" \
    /var/www/cgi-bin/gitolite-suexec-wrapper.sh/$1

# Make sure we can execute gitweb okay
<Directory "/var/www/git">
        Options ExecCGI
        AllowOverride None
        AddHandler cgi-script .cgi
        DirectoryIndex gitweb.cgi
        Order allow,deny
        Allow from all
</Directory>

# We need gl-auth-command executable
<Directory "/var/www/cgi-bin">
    <Files "gitolite-suexec-wrapper.sh">
            Order allow,deny
            Allow from all
    </Files>
</Directory>

/etc/gitweb.conf

# cat /etc/gitweb.conf | grep highlight
  $highlight_bin = "/usr/bin/highlight";
  $feature{'highlight'}{'default'} = [1];

I've also installed the kogakure gitweb theme. https://github.com/kogakure/gitweb-theme

1 Answers1

1

I experienced the same issue recently.

It seems like CentOS 6.4 uses a rather old Git release (1.7.1) which doesn't support Syntax-Highlighting for Gitweb. You've done the configuration part correctly, but Gitweb doesn't know what to do with these variables yet.

One solution would be to go the the offical Git source repo and retrieve the latest release (1.8.5) from there. This requires you to build the software from source yourself.

Workaround:

I didn't want to build the whole thing and therefore just went there to get the latest gitweb.cgi. This script is usually built from gitweb.perl, but can also be manually created by renaming it and replacing all placeholders (e.g. "++GIT_BINDIR++") as described in the README file.

This worked well for me, but it would probably be more secure and stable to rebuild and install (make & make install) the whole release.

Excodibur
  • 179
  • 1
  • 2
  • Thank you, I'll try this out and report back. Do I need to compile from source both git and gitweb? – user2875495 Oct 14 '13 at 19:11
  • As it is part of the git release I'd say you have to compile the complete git source folder to get to the gitweb.cgi you need. There also seem to exist some [Redhat/Centos RPM packages at repoforge](http://pkgs.repoforge.org/git) which might let you skip the whole building-process. However I haven't tried those. – Excodibur Oct 14 '13 at 21:47
  • I compiled git from source and copied /usr/share/gitweb to /var/www/git changed the permissions of /var/www/git to be owned by gitolite:gitolite per my apache suexec and gitolite setup, used the same configuration files restarted apache and highlight was support. Thank you Markus H. I'm happy that it works but not so happy that the default highlighting style is awful. My code files are java and I would like the Eclipse syntax but couldn't find any good reference on how to change it. This question is answered, thank you again. – user2875495 Oct 15 '13 at 23:38
  • Glad I could help. Could you please mark this answer as [accepted](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)? The Highlighting colors can easily changed by modifing the css file _/var/www/git/static/gitweb.css_. – Excodibur Oct 16 '13 at 07:28