##
##  git-apache.conf -- Git integration for Apache
##

#   NOTICE: Inside your <VirtualHost> sections you need the directives
#   "RewriteEngine on" and "RewriteOptions inherit" to get this working!

#   Git access (direct, for speed)
AliasMatch        "(?x)^/git/([^/]+)/( \
                      branches/.* | \
                      refs/.* | \
                      objects/([0-9a-f]{2}/[0-9a-f]{38} | \
                          pack/pack-[0-9a-f]{40}\.(pack|idx)) \
                  )$" \
                  @l_prefix@/var/git-apache/dat/$1/$2
<DirectoryMatch   @l_prefix@/var/git-apache/dat/[^/]+>
    Options       None
    AllowOverride none
    Order         allow,deny
    Allow         from all
</DirectoryMatch>

#   Git access (indirect, for features)
RewriteEngine     on
RewriteRule       ^/git/([^/]+)$     /git/$1/  [R,L]
RewriteRule       ^/git/([^/]+)/.*$  - \
                  [E=GIT_PROJECT_ROOT:@l_prefix@/var/git-apache/dat/$1,E=GIT_HTTP_EXPORT_ALL:true,E=GIT_APACHE_LOG:true]
ScriptAliasMatch  "(?x)^/git/[^/]+/( \
                      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 \
                  )$" \
                  @l_prefix@/cgi/git-http-backend/$1

#   Git access logging
CustomLog         @l_prefix@/var/git-apache/log/git-apache.log \
                  "%{%Y-%m-%dT%H:%M:%S}t %a %u \"%r\" %>s %I/%O %D %k:%X \"-\"" \
                  env=GIT_APACHE_LOG

#   Basic Authentication (path-specific, hence generated)
Include           "@l_prefix@/var/git-apache/etc/*.conf"

