From mboxrd@z Thu Jan 1 00:00:00 1970 From: mricon at kernel.org (Konstantin Ryabitsev) Date: Wed, 17 Jun 2015 14:47:24 -0400 Subject: CGI to transparently translate gitweb to cgit In-Reply-To: <55807E69.3060902@zytor.com> References: <55807E69.3060902@zytor.com> Message-ID: <5581C0BC.1010808@kernel.org> Hello, all: Peter Anvin wrote a CGI to transition from gitweb to cgit. I was wondering if it makes sense to incorporate it into cgit as part of contrib? http://git.zytor.com/users/hpa/cgit/gitweb2cgit.git/tree/gitweb2cgit.cgi At least hopefully this will come in handy for someone so they don't have to create terrible monstrosities with rewrite rules (like I did for kernel.org). Best, -K -------- Forwarded Message -------- Subject: Re: Migrating from gitweb to cgit Date: Tue, 16 Jun 2015 12:52:09 -0700 From: H. Peter Anvin To: Konstantin Ryabitsev On 06/12/2015 05:26 AM, Konstantin Ryabitsev wrote: > On 11/06/15 07:16 PM, H. Peter Anvin wrote: >> Cool. I ran into a set of transformation rules on the web earlier and >> hacked up a CGI script (as I just don't trust RewriteEngine to do this >> stuff sanely.) >> >> This is the latest version of it: >> >> http://git.zytor.com/users/hpa/cgit/gitweb2cgit.git/tree/gitweb2cgit.cgi > > Forgot to ask -- how does it look like on the Apache side of things? I > guess it ends up being a rewrite on the Apache side, which issues a > redirect? This is a bit more complicated than it otherwise would be, because I explicitly wanted to avoid "gitweb" or "cgit" in URLs for whatever reason, so the same namespace now contains legacy gitweb, cgit, and http-cloning URLs. Otherwise I wouldn't have had to use the rewriteengine at all and could have gotten away with aliases. ServerName git.zytor.com ServerAlias git.nasm.us DocumentRoot /var/lib/git ErrorLog /var/log/httpd/git/error_log CustomLog /var/log/httpd/git/access_log combined RedirectPermanent /var/lib/git / RedirectPermanent /pub/git / SetEnv GIT_PROJECT_ROOT /var/lib/git SetEnv GIT_HTTP_EXPORT_ALL RewriteEngine on Alias /cgit-data /usr/share/cgit ScriptAlias /cgit /var/www/cgi-bin/cgit ScriptAlias /robots.txt "/var/www/cgi-bin/robots.cgi" RewriteCond "%{QUERY_STRING}" "^.*p=.*$" RewriteRule ^/+$ /var/www/cgi-bin/gitweb2cgit.cgi [H=cgi-script] ScriptAliasMatch ^/+$ /var/www/cgi-bin/cgit ScriptAliasMatch ^/gitweb.cgi/*$ /var/www/cgi-bin/gitweb2cgit.cgi AliasMatch ^/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/lib/git/$1 AliasMatch ^/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/lib/git/$1 ScriptAliasMatch \ "(?x)^/(.*/(HEAD | \ info/refs | \ objects/info/[^/]+ | \ git-upload-pack))$" \ /usr/libexec/git-core/git-http-backend/$1 ScriptAliasMatch ^/+(.*)$ /var/www/cgi-bin/cgit/$1 -- Konstantin Ryabitsev Linux Foundation Collab Projects Montr?al, Qu?bec