diff options
-rw-r--r-- | gitweb-to-cgit-rel.conf | 239 | ||||
-rw-r--r-- | gitweb-to-cgit.conf | 453 |
2 files changed, 477 insertions, 215 deletions
diff --git a/gitweb-to-cgit-rel.conf b/gitweb-to-cgit-rel.conf new file mode 100644 index 0000000..fa9f533 --- /dev/null +++ b/gitweb-to-cgit-rel.conf @@ -0,0 +1,239 @@ + # Source: https://git.ao2.it/gitweb_cgit_migration.git + # + # Redirects mapping gitweb -> cgit + # Inspired from: http://www.clearchain.com/blog/posts/cgit-upgrade-gitweb-retired + # + # Gitweb uses get targets seperated by ; + # + # /?...;...;... + # + # p = Project + # a = Action like ( + # blob, + # blob_plain, + # commitdiff, + # commit, + # history, + # log, + # rss|atom, + # shortlog, + # summary, + # tag, + # tree, + # snapshot + # ) + # h = SHA Hash + # hb= SHA Hash Tree Base + # f= file/dir + # sf= snapshot format + # + # Cgit uses the following: + # + # /project/action/?... + # + # action ( commit, log, diff, tree, tag, patch ) + # + # id = SHA Hash + # id2 = SHA Hash + # h = head + # + # Translation rules + # + # Project is a straight redirect + # --- + # /?p=(.+)\.git; http://%{SERVER_NAME}/$1/ + # + # Action requires a mapping + # --- + # a=(blob|tree) /tree/ + # a=(blobdiff|commitdiff) /diff/ + # a=commit /commit/ + # a=(summary) / + # a=(shortlog|log|history) /log/ + # a=tag /tag/ + # a=blob_plain /blob/ + # a=rss|atom /atom + # + # Targets require mapping + # --- + # h=(.+) id=$1 + # f=(.+) /$1 + # hb=(.+) id2=$1 + # + # Now putting it all together + # + # Changed to must match URI '/git/' using all gitweb details in the query! + # Allowing to re-use /git/ for cgit, however we use /cgit/ as target for efficiency + # + RewriteEngine On + #RewriteLog /tmp/rewrite.log + #RewriteLogLevel 5 + + # blob + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob;h=(.+);hb=(.+);f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%5?id=%3;id2=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob;hb=(.+);f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%4?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+);hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%5 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3 [R,L,NE] + + # tree + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+);f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%5?id=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+);f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%4?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tree;f=(.+);h=(.+);hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%5 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tree;f=(.+);hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/?id=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tree + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/? [R,L,NE] + + # commitdiff + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blobdiff;h=(.+);hp=(.+);hb=(.+);f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/diff/%6?id2=%4;id=%3;id3=%5 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+);hp=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/diff/?id=%4;id2=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/diff/?id=%3 [R,L,NE] + + # commit + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=commit;h=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/commit/?id=%3 [R,L,NE] + + # summary + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=summary + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/? [R,L,NE] + + # shortlog + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=shortlog;h=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log/?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=shortlog + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log/? [R,L,NE] + + # log + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=log;h=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log/?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=log + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log? [R,L,NE] + + # history + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+);f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log/%5?id=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+);hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log/%3?id=%4;id2=%5 [R,L,NE] + + #RewriteBase "/git/" + #RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+) + #RewriteRule ^.*$ http://cgit.openezx.org/%1.git/log/%4?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+) + RewriteRule ^.*$ http://cgit.openezx.org/%1.git/log/%3?id=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log/?id=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+);f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log/%4?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/log/?id=%3 [R,L,NE] + + # tag + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tag;h=refs/tags/(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tag/?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=tag;h=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/tag/?id=%3 [R,L,NE] + + # blob_plain + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;h=(.+);f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/plain/%4?id=%3 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+);hb=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/plain/%3?id2=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/plain/%3 [R,L,NE] + + # rss|atom + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom);h=refsheads/(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/atom?h=%4 [R,L,NE] + + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/atom? [R,L,NE] + + # snapshot + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)(\.git);a=snapshot;h=(.+);sf=(.+) + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/snapshot/%3.tar.gz [R,L,NE] + + # Fail safes incase nothing above matches, try at least to put the person in the project + RewriteBase "/git/" + RewriteCond %{query_string} p=(.+)\.git.* + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/%1.git/? [R,L,NE] + + # Or else in the root of cgit + RewriteBase "/git/" + RewriteRule ^.*$ http://%{SERVER_NAME}/cgit/ [R,L,NE] diff --git a/gitweb-to-cgit.conf b/gitweb-to-cgit.conf index 4ca696d..20f792a 100644 --- a/gitweb-to-cgit.conf +++ b/gitweb-to-cgit.conf @@ -1,215 +1,238 @@ -<VirtualHost *:80> - ServerName git.openezx.org - - ErrorLog /var/log/apache2/git.openezx.org/error.log - CustomLog /var/log/apache2/git.openezx.org/access.log common - - # - # Redirects mapping gitweb -> cgit - # Inspired from: http://www.clearchain.com/blog/posts/cgit-upgrade-gitweb-retired - # - # Gitweb uses get targets seperated by ; - # - # /?...;...;... - # - # p = Project - # a = Action like ( - # blob, - # blob_plain, - # commitdiff, - # commit, - # history, - # log, - # rss|atom, - # shortlog, - # summary, - # tag, - # tree, - # snapshot - # ) - # h = SHA Hash - # hb= SHA Hash Tree Base - # f= file/dir - # sf= snapshot format - # - # Cgit uses the following: - # - # /project/action/?... - # - # action ( commit, log, diff, tree, tag, patch ) - # - # id = SHA Hash - # id2 = SHA Hash - # h = head - # - # Translation rules - # - # Project is a straight redirect - # --- - # /?p=(.+)\.git; http://cgit.openezx.org/$1/ - # - # Action requires a mapping - # --- - # a=(blob|tree) /tree/ - # a=(blobdiff|commitdiff) /diff/ - # a=commit /commit/ - # a=(summary) / - # a=(shortlog|log|history) /log/ - # a=tag /tag/ - # a=blob_plain /blob/ - # a=rss|atom /atom - # - # Targets require mapping - # --- - # h=(.+) id=$1 - # f=(.+) /$1 - # hb=(.+) id2=$1 - # - # Now putting it all together - # - RewriteEngine On - #RewriteLog /tmp/rewrite.log - #RewriteLogLevel 5 - - # blob - RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob/(.+)/(.+):/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=blob;h=(.+);hb=(.+);f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%5?id=%3;id2=%4 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob/(.+):/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=blob;hb=(.+);f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%4?id=%3 [R,L,NE] - - RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+);hb=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%3?id=%4;id2=%5 [R,L,NE] - - RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%3?id=%4 [R,L,NE] - - # tree - RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+)/(.+):/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+);f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%5?id=%4 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+):/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+);f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%4?id=%3 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+)/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/?id=%4 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/?id=%3 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=tree - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/? [R,L,NE] - - # commitdiff - RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+)/(.+):/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=blobdiff;h=(.+);hp=(.+);hb=(.+);f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/diff/%6?id2=%4;id=%3;id3=%5 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+)/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+);hp=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/diff/?id=%4;id2=%3 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/diff/?id=%3 [R,L,NE] - - # commit - RewriteCond %{REQUEST_URI} /(.+)(\.git)/commit/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=commit;h=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/commit/?id=%3 [R,L,NE] - - # summary - RewriteCond %{REQUEST_URI} /(.+)(\.git)/summary [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=summary - RewriteRule ^/.*$ http://cgit.openezx.org/%1/? [R,L,NE] - - # shortlog - RewriteCond %{REQUEST_URI} /(.+)(\.git)/shortlog/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=shortlog;h=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/?id=%3 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/shortlog [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=shortlog - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/? [R,L,NE] - - # log - RewriteCond %{REQUEST_URI} /(.+)(\.git)/log/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=log;h=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/?id=%3 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/log [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=log - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log? [R,L,NE] - - # history - RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+)/(.+):/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+);f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%5?id=%4 [R,L,NE] - - RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+);hb=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%3?id=%4;id2=%5 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%4?id=%3 [R,L,NE] - - RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%3?id=%4 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+)/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/?id=%4 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+);f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%4?id=%3 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/?id=%3 [R,L,NE] - - # tag - RewriteCond %{REQUEST_URI} /(.+)(\.git)/tag/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=tag;h=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/tag/?id=%3 [R,L,NE] - - # blob_plain - RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob_plain/(.+):/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;h=(.+);f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/plain/%4?id=%3 [R,L,NE] - - RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+);hb=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/plain/%3?id2=%4 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob_plain/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/plain/%3 [R,L,NE] - - # rss|atom - RewriteCond %{REQUEST_URI} /(.+)(\.git)/(rss|atom)/refs/heads/(.+) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom);h=refsheads/(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/atom?h=%4 [R,L,NE] - - RewriteCond %{REQUEST_URI} /(.+)(\.git)/(rss|atom) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/atom? [R,L,NE] - - # snapshot - RewriteCond %{REQUEST_URI} /(.+)(\.git)/snapshot/(.+)(\.tar\.gz|\.tar\.bz2) [OR] - RewriteCond %{query_string} p=(.+)(\.git);a=snapshot;h=(.+);sf=(.+) - RewriteRule ^/.*$ http://cgit.openezx.org/%1/snapshot/%3.tar.gz [R,L,NE] - - # Fail safes incase nothing above matches, try at least to put the person in the project - RewriteCond %{REQUEST_URI} /(.+)\.git.* [OR] - RewriteCond %{query_string} p=(.+)\.git.* - RewriteRule ^/.*$ http://cgit.openezx.org/%1/? [R,L,NE] - - # Or else in the root of cgit - RewriteRule ^.* http://cgit.openezx.org/ [R,L,NE] -</VirtualHost> + # Source: https://git.ao2.it/gitweb_cgit_migration.git + # + # Redirects mapping gitweb -> cgit + # Inspired from: http://www.clearchain.com/blog/posts/cgit-upgrade-gitweb-retired + # + # Gitweb uses get targets seperated by ; + # + # /?...;...;... + # + # p = Project + # a = Action like ( + # blob, + # blob_plain, + # commitdiff, + # commit, + # history, + # log, + # rss|atom, + # shortlog, + # summary, + # tag, + # tree, + # snapshot + # ) + # h = SHA Hash + # hb= SHA Hash Tree Base + # f= file/dir + # sf= snapshot format + # + # Cgit uses the following: + # + # /project/action/?... + # + # action ( commit, log, diff, tree, tag, patch ) + # + # id = SHA Hash + # id2 = SHA Hash + # h = head + # + # Translation rules + # + # Project is a straight redirect + # --- + # /?p=(.+)\.git; http://%{SERVER_NAME}/$1/ + # + # Action requires a mapping + # --- + # a=(blob|tree) /tree/ + # a=(blobdiff|commitdiff) /diff/ + # a=commit /commit/ + # a=(summary) / + # a=(shortlog|log|history) /log/ + # a=tag /tag/ + # a=blob_plain /blob/ + # a=rss|atom /atom + # + # Targets require mapping + # --- + # h=(.+) id=$1 + # f=(.+) /$1 + # hb=(.+) id2=$1 + # + # Now putting it all together + # + # Changed to must match URI '/git/' using all gitweb details in the query! + # Allowing to re-use /git/ for cgit, however we use /cgit/ as target for efficiency + # + RewriteEngine On + #RewriteLog /tmp/rewrite.log + #RewriteLogLevel 5 + + # blob + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob;h=(.+);hb=(.+);f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%5?id=%3;id2=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob;hb=(.+);f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%4?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+);hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%5 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3 [R,L,NE] + + # tree + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+);f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%5?id=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+);f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%4?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tree;f=(.+);h=(.+);hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%5 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tree;f=(.+);hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/%3?id=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/?id=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tree + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tree/? [R,L,NE] + + # commitdiff + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blobdiff;h=(.+);hp=(.+);hb=(.+);f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/diff/%6?id2=%4;id=%3;id3=%5 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+);hp=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/diff/?id=%4;id2=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/diff/?id=%3 [R,L,NE] + + # commit + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=commit;h=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/commit/?id=%3 [R,L,NE] + + # summary + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=summary + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/? [R,L,NE] + + # shortlog + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=shortlog;h=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log/?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=shortlog + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log/? [R,L,NE] + + # log + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=log;h=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log/?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=log + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log? [R,L,NE] + + # history + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+);f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log/%5?id=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+);hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log/%3?id=%4;id2=%5 [R,L,NE] + + #RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+) + #RewriteRule ^/.*$ http://cgit.openezx.org/%1.git/log/%4?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+) + RewriteRule ^/.*$ http://cgit.openezx.org/%1.git/log/%3?id=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log/?id=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+);f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log/%4?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/log/?id=%3 [R,L,NE] + + # tag + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tag;h=refs/tags/(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tag/?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=tag;h=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/tag/?id=%3 [R,L,NE] + + # blob_plain + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;h=(.+);f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/plain/%4?id=%3 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+);hb=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/plain/%3?id2=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/plain/%3 [R,L,NE] + + # rss|atom + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom);h=refsheads/(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/atom?h=%4 [R,L,NE] + + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/atom? [R,L,NE] + + # snapshot + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)(\.git);a=snapshot;h=(.+);sf=(.+) + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/snapshot/%3.tar.gz [R,L,NE] + + # Fail safes incase nothing above matches, try at least to put the person in the project + RewriteCond %{REQUEST_URI} ^/git/$ + RewriteCond %{query_string} p=(.+)\.git.* + RewriteRule ^/.*$ http://%{SERVER_NAME}/cgit/%1.git/? [R,L,NE] + + # Or else in the root of cgit + #RewriteCond %{REQUEST_URI} ^/git/$ + #RewriteRule ^.* http://%{SERVER_NAME}/cgit/ [R,L,NE] |