gitweb / READMEon commit format-patch: ignore ui.color (787570c)
   1GIT web Interface
   2=================
   3
   4The one working on:
   5  http://git.kernel.org/
   6
   7From the git version 1.4.0 gitweb is bundled with git.
   8
   9
  10Runtime gitweb configuration
  11----------------------------
  12
  13You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
  14(defaults to 'gitweb_config.perl' in the same directory as the CGI), and
  15as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
  16The most notable thing that is not configurable at compile time are the
  17optional features, stored in the '%features' variable.
  18
  19Ultimate description on how to reconfigure the default features setting
  20in your `GITWEB_CONFIG` or per-project in `project.git/config` can be found
  21as comments inside 'gitweb.cgi'.
  22
  23See also the "Gitweb config file" (with an example of config file), and
  24the "Gitweb repositories" sections in INSTALL file for gitweb.
  25
  26
  27The gitweb config file is a fragment of perl code. You can set variables
  28using "our $variable = value"; text from "#" character until the end
  29of a line is ignored. See perlsyn(1) man page for details.
  30
  31Below is the list of variables which you might want to set in gitweb config.
  32See the top of 'gitweb.cgi' for the full list of variables and their
  33descriptions.
  34
  35Gitweb config file variables
  36~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37
  38You can set, among others, the following variables in gitweb config files
  39(with the exception of $projectroot and $projects_list this list does
  40not include variables usually directly set during build):
  41 * $GIT
  42   Core git executable to use.  By default set to "$GIT_BINDIR/git", which
  43   in turn is by default set to "$(bindir)/git".  If you use git from binary
  44   package, set this to "/usr/bin/git".  This can just be "git" if your
  45   webserver has a sensible PATH.  If you have multiple git versions
  46   installed it can be used to choose which one to use.
  47 * $version
  48   Gitweb version, set automatically when creating gitweb.cgi from
  49   gitweb.perl. You might want to modify it if you are running modified
  50   gitweb.
  51 * $projectroot
  52   Absolute filesystem path which will be prepended to project path;
  53   the path to repository is $projectroot/$project.  Set to
  54   $GITWEB_PROJECTROOT during installation.  This variable have to be
  55   set correctly for gitweb to find repositories.
  56 * $projects_list
  57   Source of projects list, either directory to scan, or text file
  58   with list of repositories (in the "<URI-encoded repository path> SP
  59   <URI-encoded repository owner>" line format; actually there can be
  60   any sequence of whitespace in place of space (SP)).  Set to
  61   $GITWEB_LIST during installation.  If empty, $projectroot is used
  62   to scan for repositories.
  63 * $my_url, $my_uri
  64   Full URL and absolute URL of gitweb script;
  65   in earlier versions of gitweb you might have need to set those
  66   variables, now there should be no need to do it.  See
  67   $per_request_config if you need to set them still.
  68 * $base_url
  69   Base URL for relative URLs in pages generated by gitweb,
  70   (e.g. $logo, $favicon, @stylesheets if they are relative URLs),
  71   needed and used only for URLs with nonempty PATH_INFO via
  72   <base href="$base_url">.  Usually gitweb sets its value correctly,
  73   and there is no need to set this variable, e.g. to $my_uri or "/".
  74   See $per_request_config if you need to set it anyway.
  75 * $home_link
  76   Target of the home link on top of all pages (the first part of view
  77   "breadcrumbs").  By default set to absolute URI of a page ($my_uri).
  78 * @stylesheets
  79   List of URIs of stylesheets (relative to base URI of a page). You
  80   might specify more than one stylesheet, for example use gitweb.css
  81   as base, with site specific modifications in separate stylesheet
  82   to make it easier to upgrade gitweb. You can add 'site' stylesheet
  83   for example by using
  84      push @stylesheets, "gitweb-site.css";
  85   in the gitweb config file.
  86 * $logo_url, $logo_label
  87   URI and label (title) of GIT logo link (or your site logo, if you choose
  88   to use different logo image). By default they point to git homepage;
  89   in the past they pointed to git documentation at www.kernel.org.
  90 * $projects_list_description_width
  91   The width (in characters) of the projects list "Description" column.
  92   Longer descriptions will be cut (trying to cut at word boundary);
  93   full description is available as 'title' attribute (usually shown on
  94   mouseover).  By default set to 25, which might be too small if you
  95   use long project descriptions.
  96 * $projects_list_group_categories
  97   Enables the grouping of projects by category on the project list page.
  98   The category of a project is determined by the $GIT_DIR/category
  99   file or the 'gitweb.category' variable in its repository configuration.
 100   Disabled by default.
 101 * $project_list_default_category
 102   Default category for projects for which none is specified.  If set
 103   to the empty string, such projects will remain uncategorized and
 104   listed at the top, above categorized projects.
 105 * @git_base_url_list
 106   List of git base URLs used for URL to where fetch project from, shown
 107   in project summary page.  Full URL is "$git_base_url/$project".
 108   You can setup multiple base URLs (for example one for  git:// protocol
 109   access, and one for http:// "dumb" protocol access).  Note that per
 110   repository configuration in 'cloneurl' file, or as values of gitweb.url
 111   project config.
 112 * $default_blob_plain_mimetype
 113   Default mimetype for blob_plain (raw) view, if mimetype checking
 114   doesn't result in some other type; by default 'text/plain'.
 115 * $default_text_plain_charset
 116   Default charset for text files. If not set, web server configuration
 117   would be used.
 118 * $mimetypes_file
 119   File to use for (filename extension based) guessing of MIME types before
 120   trying /etc/mime.types. Path, if relative, is taken currently as
 121   relative to the current git repository.
 122 * $fallback_encoding
 123   Gitweb assumes this charset if line contains non-UTF-8 characters.
 124   Fallback decoding is used without error checking, so it can be even
 125   'utf-8'. Value must be valid encoding; see Encoding::Supported(3pm) man
 126   page for a list.   By default 'latin1', aka. 'iso-8859-1'.
 127 * @diff_opts
 128   Rename detection options for git-diff and git-diff-tree. By default
 129   ('-M'); set it to ('-C') or ('-C', '-C') to also detect copies, or
 130   set it to () if you don't want to have renames detection.
 131 * $prevent_xss
 132   If true, some gitweb features are disabled to prevent content in
 133   repositories from launching cross-site scripting (XSS) attacks.  Set this
 134   to true if you don't trust the content of your repositories. The default
 135   is false.
 136 * $maxload
 137   Used to set the maximum load that we will still respond to gitweb queries.
 138   If server load exceed this value then return "503 Service Unavailable" error.
 139   Server load is taken to be 0 if gitweb cannot determine its value.  Set it to
 140   undefined value to turn it off.  The default is 300.
 141 * $highlight_bin
 142   Path to the highlight executable to use (must be the one from
 143   http://www.andre-simon.de due to assumptions about parameters and output).
 144   Useful if highlight is not installed on your webserver's PATH.
 145   [Default: highlight]
 146 * $per_request_config
 147   If set to code reference, it would be run once per each request.  You can
 148   set parts of configuration that change per session, e.g. by setting it to
 149     sub { $ENV{GL_USER} = $cgi->remote_user || "gitweb"; }
 150   Otherwise it is treated as boolean value: if true gitweb would process
 151   config file once per request, if false it would process config file only
 152   once.  Note: $my_url, $my_uri, and $base_url are overwritten with
 153   their default values before every request, so if you want to change
 154   them, be sure to set this variable to true or a code reference effecting
 155   the desired changes.  The default is true.
 156
 157Projects list file format
 158~~~~~~~~~~~~~~~~~~~~~~~~~
 159
 160Instead of having gitweb find repositories by scanning filesystem starting
 161from $projectroot (or $projects_list, if it points to directory), you can
 162provide list of projects by setting $projects_list to a text file with list
 163of projects (and some additional info).  This file uses the following
 164format:
 165
 166One record (for project / repository) per line, whitespace separated fields;
 167does not support (at least for now) lines continuation (newline escaping).
 168Leading and trailing whitespace are ignored, any run of whitespace can be
 169used as field separator (rules for Perl's "split(' ', $line)").  Keyed by
 170the first field, which is project name, i.e. path to repository GIT_DIR
 171relative to $projectroot.  Fields use modified URI encoding, defined in
 172RFC 3986, section 2.1 (Percent-Encoding), or rather "Query string encoding"
 173(see http://en.wikipedia.org/wiki/Query_string#URL_encoding), the difference
 174being that SP (' ') can be encoded as '+' (and therefore '+' has to be also
 175percent-encoded).  Reserved characters are: '%' (used for encoding), '+'
 176(can be used to encode SPACE), all whitespace characters as defined in Perl,
 177including SP, TAB and LF, (used to separate fields in a record).
 178
 179Currently list of fields is
 180 * <repository path>  - path to repository GIT_DIR, relative to $projectroot
 181 * <repository owner> - displayed as repository owner, preferably full name,
 182                        or email, or both
 183
 184You can additionally use $projects_list file to limit which repositories
 185are visible, and together with $strict_export to limit access to
 186repositories (see "Gitweb repositories" section in gitweb/INSTALL).
 187
 188
 189Per-repository gitweb configuration
 190~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 191
 192You can also configure individual repositories shown in gitweb by creating
 193file in the GIT_DIR of git repository, or by setting some repo configuration
 194variable (in GIT_DIR/config).
 195
 196You can use the following files in repository:
 197 * README.html
 198   A .html file (HTML fragment) which is included on the gitweb project
 199   summary page inside <div> block element. You can use it for longer
 200   description of a project, to provide links (for example to project's
 201   homepage), etc. This is recognized only if XSS prevention is off
 202   ($prevent_xss is false); a way to include a readme safely when XSS
 203   prevention is on may be worked out in the future.
 204 * description (or gitweb.description)
 205   Short (shortened by default to 25 characters in the projects list page)
 206   single line description of a project (of a repository). Plain text file;
 207   HTML will be escaped. By default set to
 208     Unnamed repository; edit this file to name it for gitweb.
 209   from the template during repository creation. You can use the
 210   gitweb.description repo configuration variable, but the file takes
 211   precedence.
 212 * category (or gitweb.category)
 213   Singe line category of a project, used to group projects if
 214   $projects_list_group_categories is enabled. By default (file and
 215   configuration variable absent), uncategorized projects are put in
 216   the $project_list_default_category category. You can use the
 217   gitweb.category repo configuration variable, but the file takes
 218   precedence.
 219 * cloneurl (or multiple-valued gitweb.url)
 220   File with repository URL (used for clone and fetch), one per line.
 221   Displayed in the project summary page. You can use multiple-valued
 222   gitweb.url repository configuration variable for that, but the file
 223   takes precedence.
 224 * gitweb.owner
 225   You can use the gitweb.owner repository configuration variable to set
 226   repository's owner. It is displayed in the project list and summary
 227   page. If it's not set, filesystem directory's owner is used
 228   (via GECOS field / real name field from getpwiud(3)).
 229 * various gitweb.* config variables (in config)
 230   Read description of %feature hash for detailed list, and some
 231   descriptions.
 232
 233
 234Webserver configuration
 235-----------------------
 236
 237If you want to have one URL for both gitweb and your http://
 238repositories, you can configure apache like this:
 239
 240<VirtualHost *:80>
 241    ServerName          git.example.org
 242    DocumentRoot        /pub/git
 243    SetEnv                      GITWEB_CONFIG   /etc/gitweb.conf
 244
 245    # turning on mod rewrite
 246    RewriteEngine on
 247
 248    # make the front page an internal rewrite to the gitweb script
 249    RewriteRule ^/$  /cgi-bin/gitweb.cgi
 250
 251    # make access for "dumb clients" work
 252    RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI}  [L,PT]
 253</VirtualHost>
 254
 255The above configuration expects your public repositories to live under
 256/pub/git and will serve them as http://git.domain.org/dir-under-pub-git,
 257both as cloneable GIT URL and as browseable gitweb interface.
 258If you then start your git-daemon with --base-path=/pub/git --export-all
 259then you can even use the git:// URL with exactly the same path.
 260
 261Setting the environment variable GITWEB_CONFIG will tell gitweb to use
 262the named file (i.e. in this example /etc/gitweb.conf) as a
 263configuration for gitweb.  Perl variables defined in here will
 264override the defaults given at the head of the gitweb.perl (or
 265gitweb.cgi).  Look at the comments in that file for information on
 266which variables and what they mean.
 267
 268If you use the rewrite rules from the example you'll likely also need
 269something like the following in your gitweb.conf (or gitweb_config.perl) file:
 270
 271  @stylesheets = ("/some/absolute/path/gitweb.css");
 272  $my_uri = "/";
 273  $home_link = "/";
 274
 275
 276Webserver configuration with multiple projects' root
 277----------------------------------------------------
 278
 279If you want to use gitweb with several project roots you can edit your apache
 280virtual host and gitweb.conf configuration files like this :
 281
 282virtual host configuration :
 283
 284<VirtualHost *:80>
 285    ServerName                  git.example.org
 286    DocumentRoot                /pub/git
 287    SetEnv                              GITWEB_CONFIG   /etc/gitweb.conf
 288
 289    # turning on mod rewrite
 290    RewriteEngine on
 291
 292    # make the front page an internal rewrite to the gitweb script
 293    RewriteRule ^/$             /cgi-bin/gitweb.cgi [QSA,L,PT]
 294
 295    # look for a public_git folder in unix users' home
 296    # http://git.example.org/~<user>/
 297    RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$   /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
 298
 299    # http://git.example.org/+<user>/
 300    #RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$  /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
 301
 302    # http://git.example.org/user/<user>/
 303    #RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
 304
 305    # defined list of project roots
 306    RewriteRule ^/scm(/|/gitweb.cgi)?$          /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT]
 307    RewriteRule ^/var(/|/gitweb.cgi)?$          /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT]
 308
 309    # make access for "dumb clients" work
 310    RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI}  [L,PT]
 311</VirtualHost>
 312
 313gitweb.conf configuration :
 314
 315$projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git";
 316
 317These configurations enable two things. First, each unix user (<user>) of the
 318server will be able to browse through gitweb git repositories found in
 319~/public_git/ with the following url : http://git.example.org/~<user>/
 320
 321If you do not want this feature on your server just remove the second rewrite rule.
 322
 323If you already use mod_userdir in your virtual host or you don't want to use
 324the '~' as first character just comment or remove the second rewrite rule and
 325uncomment one of the following according to what you want.
 326
 327Second, repositories found in /pub/scm/ and /var/git/ will be accesible
 328through http://git.example.org/scm/ and http://git.example.org/var/.
 329You can add as many project roots as you want by adding rewrite rules like the
 330third and the fourth.
 331
 332
 333PATH_INFO usage
 334-----------------------
 335If you enable PATH_INFO usage in gitweb by putting
 336
 337   $feature{'pathinfo'}{'default'} = [1];
 338
 339in your gitweb.conf, it is possible to set up your server so that it
 340consumes and produces URLs in the form
 341
 342http://git.example.com/project.git/shortlog/sometag
 343
 344by using a configuration such as the following, that assumes that
 345/var/www/gitweb is the DocumentRoot of your webserver, and that it
 346contains the gitweb.cgi script and complementary static files
 347(stylesheet, favicon):
 348
 349<VirtualHost *:80>
 350        ServerAlias git.example.com
 351
 352        DocumentRoot /var/www/gitweb
 353
 354        <Directory /var/www/gitweb>
 355                Options ExecCGI
 356                AddHandler cgi-script cgi
 357
 358                DirectoryIndex gitweb.cgi
 359
 360                RewriteEngine On
 361                RewriteCond %{REQUEST_FILENAME} !-f
 362                RewriteCond %{REQUEST_FILENAME} !-d
 363                RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
 364        </Directory>
 365</VirtualHost>
 366
 367The rewrite rule guarantees that existing static files will be properly
 368served, whereas any other URL will be passed to gitweb as PATH_INFO
 369parameter.
 370
 371Notice that in this case you don't need special settings for
 372@stylesheets, $my_uri and $home_link, but you lose "dumb client" access
 373to your project .git dirs. A possible workaround for the latter is the
 374following: in your project root dir (e.g. /pub/git) have the projects
 375named without a .git extension (e.g. /pub/git/project instead of
 376/pub/git/project.git) and configure Apache as follows:
 377
 378<VirtualHost *:80>
 379        ServerAlias git.example.com
 380
 381        DocumentRoot /var/www/gitweb
 382
 383        AliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3
 384        <Directory /var/www/gitweb>
 385                Options ExecCGI
 386                AddHandler cgi-script cgi
 387
 388                DirectoryIndex gitweb.cgi
 389
 390                RewriteEngine On
 391                RewriteCond %{REQUEST_FILENAME} !-f
 392                RewriteCond %{REQUEST_FILENAME} !-d
 393                RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
 394        </Directory>
 395</VirtualHost>
 396
 397The additional AliasMatch makes it so that
 398
 399http://git.example.com/project.git
 400
 401will give raw access to the project's git dir (so that the project can
 402be cloned), while
 403
 404http://git.example.com/project
 405
 406will provide human-friendly gitweb access.
 407
 408This solution is not 100% bulletproof, in the sense that if some project
 409has a named ref (branch, tag) starting with 'git/', then paths such as
 410
 411http://git.example.com/project/command/abranch..git/abranch
 412
 413will fail with a 404 error.
 414
 415
 416
 417Originally written by:
 418  Kay Sievers <kay.sievers@vrfy.org>
 419
 420Any comment/question/concern to:
 421  Git mailing list <git@vger.kernel.org>