1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
\r
4 <sect2 lang="en" id="gitweb(1)">
\r
5 <title>gitweb(1)</title>
\r
7 <primary>gitweb(1)</primary>
\r
9 <simplesect id="gitweb(1)__name">
\r
11 <simpara>gitweb - Git web interface (web frontend to Git repositories)</simpara>
\r
13 <simplesect id="gitweb(1)__synopsis">
\r
14 <title>SYNOPSIS</title>
\r
15 <simpara>To get started with gitweb, run <xref linkend="git-instaweb(1)" /> from a git repository.
\r
16 This would configure and start your web server, and run web browser pointing to
\r
19 <simplesect id="gitweb(1)__description">
\r
20 <title>DESCRIPTION</title>
\r
21 <simpara>Gitweb provides a web interface to git repositories. Its features include:</simpara>
\r
25 Viewing multiple Git repositories with common root.
\r
30 Browsing every revision of the repository.
\r
35 Viewing the contents of files in the repository at any revision.
\r
40 Viewing the revision log of branches, history of files and directories,
\r
41 see what was changed when, by who.
\r
46 Viewing the blame/annotation details of any file (if enabled).
\r
51 Generating RSS and Atom feeds of commits, for any branch.
\r
52 The feeds are auto-discoverable in modern web browsers.
\r
57 Viewing everything that was changed in a revision, and step through
\r
58 revisions one at a time, viewing the history of the repository.
\r
63 Finding commits which commit messages matches given search term.
\r
67 <simpara>See <ulink url="http://git.kernel.org/?p=git/git.git;a=tree;f=gitweb">http://git.kernel.org/?p=git/git.git;a=tree;f=gitweb</ulink>[] or
\r
68 <ulink url="http://repo.or.cz/w/git.git/tree/HEAD:/gitweb/">http://repo.or.cz/w/git.git/tree/HEAD:/gitweb/</ulink>[] for gitweb source code,
\r
69 browsed using gitweb itself.</simpara>
\r
71 <simplesect id="gitweb(1)__configuration">
\r
72 <title>CONFIGURATION</title>
\r
73 <simpara>Various aspects of gitweb's behavior can be controlled through the configuration
\r
74 file <emphasis>gitweb_config.perl</emphasis> or <emphasis>/etc/gitweb.conf</emphasis>. See the <xref linkend="gitweb.conf(5)" />
\r
75 for details.</simpara>
\r
76 <section id="gitweb(1)__repositories">
\r
77 <title>Repositories</title>
\r
78 <simpara>Gitweb can show information from one or more Git repositories. These
\r
79 repositories have to be all on local filesystem, and have to share common
\r
80 repository root, i.e. be all under a single parent repository (but see also
\r
81 "Advanced web server setup" section, "Webserver configuration with multiple
\r
82 projects' root" subsection).</simpara>
\r
83 <screen>our $projectroot = '/path/to/parent/directory';</screen>
\r
84 <simpara>The default value for <emphasis>$projectroot</emphasis> is <emphasis>/pub/git</emphasis>. You can change it during
\r
85 building gitweb via <emphasis>GITWEB_PROJECTROOT</emphasis> build configuration variable.</simpara>
\r
86 <simpara>By default all git repositories under <emphasis>$projectroot</emphasis> are visible and available
\r
87 to gitweb. The list of projects is generated by default by scanning the
\r
88 <emphasis>$projectroot</emphasis> directory for git repositories (for object databases to be
\r
89 more exact; gitweb is not interested in a working area, and is best suited
\r
90 to showing "bare" repositories).</simpara>
\r
91 <simpara>The name of the repository in gitweb is the path to its <emphasis>$GIT_DIR</emphasis> (its object
\r
92 database) relative to <emphasis>$projectroot</emphasis>. Therefore the repository $repo can be
\r
93 found at "$projectroot/$repo".</simpara>
\r
95 <section id="gitweb(1)__projects_list_file_format">
\r
96 <title>Projects list file format</title>
\r
97 <simpara>Instead of having gitweb find repositories by scanning filesystem
\r
98 starting from $projectroot, you can provide a pre-generated list of
\r
99 visible projects by setting <emphasis>$projects_list</emphasis> to point to a plain text
\r
100 file with a list of projects (with some additional info).</simpara>
\r
101 <simpara>This file uses the following format:</simpara>
\r
105 One record (for project / repository) per line; does not support line
\r
106 continuation (newline escaping).
\r
111 Leading and trailing whitespace are ignored.
\r
116 Whitespace separated fields; any run of whitespace can be used as field
\r
117 separator (rules for Perl's "<emphasis>split(" ", $line)</emphasis>").
\r
122 Fields use modified URI encoding, defined in RFC 3986, section 2.1
\r
123 (Percent-Encoding), or rather "Query string encoding" (see
\r
124 URL_encoding), the difference
\r
125 being that SP (" ") can be encoded as "+" (and therefore "+" has to be
\r
126 also percent-encoded).
\r
128 <simpara>Reserved characters are: "%" (used for encoding), "+" (can be used to
\r
129 encode SPACE), all whitespace characters as defined in Perl, including SP,
\r
130 TAB and LF, (used to separate fields in a record).</simpara>
\r
134 Currently recognized fields are:
\r
139 <repository path>
\r
143 path to repository GIT_DIR, relative to <emphasis>$projectroot</emphasis>
\r
149 <repository owner>
\r
153 displayed as repository owner, preferably full name, or email,
\r
161 <simpara>You can generate the projects list index file using the project_index action
\r
162 (the <emphasis>TXT</emphasis> link on projects list page) directly from gitweb; see also
\r
163 "Generating projects list using gitweb" section below.</simpara>
\r
164 <simpara>Example contents:</simpara>
\r
165 <screen>foo.git Joe+R+Hacker+<joe@example.com>
\r
166 foo/bar.git O+W+Ner+<owner@example.org></screen>
\r
167 <simpara>By default this file controls only which projects are <emphasis role="strong">visible</emphasis> on projects
\r
168 list page (note that entries that do not point to correctly recognized git
\r
169 repositories won't be displayed by gitweb). Even if a project is not
\r
170 visible on projects list page, you can view it nevertheless by hand-crafting
\r
171 a gitweb URL. By setting <emphasis>$strict_export</emphasis> configuration variable (see
\r
172 <xref linkend="gitweb.conf(5)" />) to true value you can allow viewing only of
\r
173 repositories also shown on the overview page (i.e. only projects explicitly
\r
174 listed in projects list file will be accessible).</simpara>
\r
176 <section id="gitweb(1)__generating_projects_list_using_gitweb">
\r
177 <title>Generating projects list using gitweb</title>
\r
178 <simpara>We assume that GITWEB_CONFIG has its default Makefile value, namely
\r
179 <emphasis>gitweb_config.perl</emphasis>. Put the following in <emphasis>gitweb_make_index.perl</emphasis> file:</simpara>
\r
180 <screen>read_config_file("gitweb_config.perl");
\r
181 $projects_list = $projectroot;</screen>
\r
182 <simpara>Then create the following script to get list of project in the format
\r
183 suitable for GITWEB_LIST build configuration variable (or
\r
184 <emphasis>$projects_list</emphasis> variable in gitweb config):</simpara>
\r
187 export GITWEB_CONFIG="gitweb_make_index.perl"
\r
188 export GATEWAY_INTERFACE="CGI/1.1"
\r
189 export HTTP_ACCEPT="*/*"
\r
190 export REQUEST_METHOD="GET"
\r
191 export QUERY_STRING="a=project_index"
\r
193 perl -- /var/www/cgi-bin/gitweb.cgi</screen>
\r
194 <simpara>Run this script and save its output to a file. This file could then be used
\r
195 as projects list file, which means that you can set <emphasis>$projects_list</emphasis> to its
\r
196 filename.</simpara>
\r
198 <section id="gitweb(1)__controlling_access_to_git_repositories">
\r
199 <title>Controlling access to git repositories</title>
\r
200 <simpara>By default all git repositories under <emphasis>$projectroot</emphasis> are visible and
\r
201 available to gitweb. You can however configure how gitweb controls access
\r
202 to repositories.</simpara>
\r
206 As described in "Projects list file format" section, you can control which
\r
207 projects are <emphasis role="strong">visible</emphasis> by selectively including repositories in projects
\r
208 list file, and setting <emphasis>$projects_list</emphasis> gitweb configuration variable to
\r
209 point to it. With <emphasis>$strict_export</emphasis> set, projects list file can be used to
\r
210 control which repositories are <emphasis role="strong">available</emphasis> as well.
\r
215 You can configure gitweb to only list and allow viewing of the explicitly
\r
216 exported repositories, via <emphasis>$export_ok</emphasis> variable in gitweb config file; see
\r
217 <xref linkend="gitweb.conf(5)" /> manpage. If it evaluates to true, gitweb shows
\r
218 repositories only if this file named by <emphasis>$export_ok</emphasis> exists in its object
\r
219 database (if directory has the magic file named <emphasis>$export_ok</emphasis>).
\r
221 <simpara>For example <xref linkend="git-daemon(1)" /> by default (unless <emphasis>--export-all</emphasis> option
\r
222 is used) allows pulling only for those repositories that have
\r
223 <emphasis>git-daemon-export-ok</emphasis> file. Adding</simpara>
\r
224 <screen>our $export_ok = "git-daemon-export-ok";</screen>
\r
225 <simpara>makes gitweb show and allow access only to those repositories that can be
\r
226 fetched from via <emphasis>git://</emphasis> protocol.</simpara>
\r
230 Finally, it is possible to specify an arbitrary perl subroutine that will
\r
231 be called for each repository to determine if it can be exported. The
\r
232 subroutine receives an absolute path to the project (repository) as its only
\r
233 parameter (i.e. "$projectroot/$project").
\r
235 <simpara>For example, if you use mod_perl to run the script, and have dumb
\r
236 HTTP protocol authentication configured for your repositories, you
\r
237 can use the following hook to allow access only if the user is
\r
238 authorized to read the files:</simpara>
\r
239 <screen>$export_auth_hook = sub {
\r
240 use Apache2::SubRequest ();
\r
241 use Apache2::Const -compile => qw(HTTP_OK);
\r
242 my $path = "$_[0]/HEAD";
\r
243 my $r = Apache2::RequestUtil->request;
\r
244 my $sub = $r->lookup_file($path);
\r
245 return $sub->filename eq $path
\r
246 && $sub->status == Apache2::Const::HTTP_OK;
\r
251 <section id="gitweb(1)__per_repository_gitweb_configuration">
\r
252 <title>Per-repository gitweb configuration</title>
\r
253 <simpara>You can configure individual repositories shown in gitweb by creating file
\r
254 in the <emphasis>GIT_DIR</emphasis> of git repository, or by setting some repo configuration
\r
255 variable (in <emphasis>GIT_DIR/config</emphasis>, see <xref linkend="git-config(1)" />).</simpara>
\r
256 <simpara>You can use the following files in repository:</simpara>
\r
264 A html file (HTML fragment) which is included on the gitweb project
\r
265 "summary" page inside <emphasis><div></emphasis> block element. You can use it for longer
\r
266 description of a project, to provide links (for example to project's
\r
267 homepage), etc. This is recognized only if XSS prevention is off
\r
268 (<emphasis>$prevent_xss</emphasis> is false, see <xref linkend="gitweb.conf(5)" />); a way to include
\r
269 a README safely when XSS prevention is on may be worked out in the
\r
276 description (or <emphasis>gitweb.description</emphasis>)
\r
280 Short (shortened to <emphasis>$projects_list_description_width</emphasis> in the projects
\r
281 list page, which is 25 characters by default; see
\r
282 <xref linkend="gitweb.conf(5)" />) single line description of a project (of a
\r
283 repository). Plain text file; HTML will be escaped. By default set to
\r
285 <screen>Unnamed repository; edit this file to name it for gitweb.</screen>
\r
286 <simpara>from the template during repository creation, usually installed in
\r
287 <emphasis>/usr/share/git-core/templates/</emphasis>. You can use the <emphasis>gitweb.description</emphasis> repo
\r
288 configuration variable, but the file takes precedence.</simpara>
\r
293 category (or <emphasis>gitweb.category</emphasis>)
\r
297 Singe line category of a project, used to group projects if
\r
298 <emphasis>$projects_list_group_categories</emphasis> is enabled. By default (file and
\r
299 configuration variable absent), uncategorized projects are put in the
\r
300 <emphasis>$project_list_default_category</emphasis> category. You can use the
\r
301 <emphasis>gitweb.category</emphasis> repo configuration variable, but the file takes
\r
304 <simpara>The configuration variables <emphasis>$projects_list_group_categories</emphasis> and
\r
305 <emphasis>$project_list_default_category</emphasis> are described in <xref linkend="gitweb.conf(5)" /></simpara>
\r
310 cloneurl (or multiple-valued <emphasis>gitweb.url</emphasis>)
\r
314 File with repository URL (used for clone and fetch), one per line.
\r
315 Displayed in the project summary page. You can use multiple-valued
\r
316 <emphasis>gitweb.url</emphasis> repository configuration variable for that, but the file
\r
319 <simpara>This is per-repository enhancement / version of global prefix-based
\r
320 <emphasis>@git_base_url_list</emphasis> gitweb configuration variable (see
\r
321 <xref linkend="gitweb.conf(5)" />).</simpara>
\r
330 You can use the <emphasis>gitweb.owner</emphasis> repository configuration variable to set
\r
331 repository's owner. It is displayed in the project list and summary
\r
334 <simpara>If it's not set, filesystem directory's owner is used (via GECOS field,
\r
335 i.e. real name field from <emphasis role="strong">getpwuid</emphasis>(3)) if <emphasis>$projects_list</emphasis> is unset
\r
336 (gitweb scans <emphasis>$projectroot</emphasis> for repositories); if <emphasis>$projects_list</emphasis>
\r
337 points to file with list of repositories, then project owner defaults to
\r
338 value from this file for given repository.</simpara>
\r
343 various <emphasis>gitweb.*</emphasis> config variables (in config)
\r
347 Read description of <emphasis>%feature</emphasis> hash for detailed list, and descriptions.
\r
348 See also "Configuring gitweb features" section in <xref linkend="gitweb.conf(5)" />
\r
355 <simplesect id="gitweb(1)__actions_and_urls">
\r
356 <title>ACTIONS, AND URLS</title>
\r
357 <simpara>Gitweb can use path_info (component) based URLs, or it can pass all necessary
\r
358 information via query parameters. The typical gitweb URLs are broken down in to
\r
359 five components:</simpara>
\r
360 <screen>.../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments></screen>
\r
368 The repository the action will be performed on.
\r
370 <simpara>All actions except for those that list all available projects,
\r
371 in whatever form, require this parameter.</simpara>
\r
380 The action that will be run. Defaults to <emphasis>projects_list</emphasis> if repo
\r
381 is not set, and to <emphasis>summary</emphasis> otherwise.
\r
391 Revision shown. Defaults to HEAD.
\r
401 The path within the <repository> that the action is performed on,
\r
402 for those actions that require it.
\r
412 Any arguments that control the behaviour of the action.
\r
417 <simpara>Some actions require or allow to specify two revisions, and sometimes even two
\r
418 pathnames. In most general form such path_info (component) based gitweb URL
\r
419 looks like this:</simpara>
\r
420 <screen>.../gitweb.cgi/<repo>/<action>/<revision_from>:/<path_from>..<revision_to>:/<path_to>?<arguments></screen>
\r
421 <simpara>Each action is implemented as a subroutine, and must be present in %actions
\r
422 hash. Some actions are disabled by default, and must be turned on via feature
\r
423 mechanism. For example to enable <emphasis>blame</emphasis> view add the following to gitweb
\r
424 configuration file:</simpara>
\r
425 <screen>$feature{'blame'}{'default'} = [1];</screen>
\r
426 <section id="gitweb(1)__actions">
\r
427 <title>Actions:</title>
\r
428 <simpara>The standard actions are:</simpara>
\r
436 Lists the available Git repositories. This is the default command if no
\r
437 repository is specified in the URL.
\r
447 Displays summary about given repository. This is the default command if
\r
448 no action is specified in URL, and only repository is specified.
\r
461 Lists all local or all remote-tracking branches in given repository.
\r
463 <simpara>The latter is not available by default, unless configured.</simpara>
\r
472 List all tags (lightweight and annotated) in given repository.
\r
485 Shows the files and directories in a given repository path, at given
\r
486 revision. This is default command if no action is specified in the URL,
\r
497 Returns the raw data for the file in given repository, at given path and
\r
498 revision. Links to this action are marked <emphasis>raw</emphasis>.
\r
508 Shows the difference between two revisions of the same file.
\r
521 Shows the blame (also called annotation) information for a file. On a
\r
522 per line basis it shows the revision in which that line was last changed
\r
523 and the user that committed the change. The incremental version (which
\r
524 if configured is used automatically when JavaScript is enabled) uses
\r
525 Ajax to incrementally add blame info to the contents of given file.
\r
527 <simpara>This action is disabled by default for performance reasons.</simpara>
\r
539 Shows information about a specific commit in a repository. The <emphasis>commit</emphasis>
\r
540 view shows information about commit in more detail, the <emphasis>commitdiff</emphasis>
\r
541 action shows changeset for given commit.
\r
551 Returns the commit in plain text mail format, suitable for applying with
\r
552 <xref linkend="git-am(1)" />.
\r
562 Display specific annotated tag (tag object).
\r
575 Shows log information (commit message or just commit subject) for a
\r
576 given branch (starting from given revision).
\r
578 <simpara>The <emphasis>shortlog</emphasis> view is more compact; it shows one commit per line.</simpara>
\r
587 Shows history of the file or directory in a given repository path,
\r
588 starting from given revision (defaults to HEAD, i.e. default branch).
\r
590 <simpara>This view is similar to <emphasis>shortlog</emphasis> view.</simpara>
\r
602 Generates an RSS (or Atom) feed of changes to repository.
\r
609 <simplesect id="gitweb(1)__webserver_configuration">
\r
610 <title>WEBSERVER CONFIGURATION</title>
\r
611 <simpara>This section explains how to configure some common webservers to run gitweb. In
\r
612 all cases, <emphasis>/path/to/gitweb</emphasis> in the examples is the directory you ran installed
\r
613 gitweb in, and contains <emphasis>gitweb_config.perl</emphasis>.</simpara>
\r
614 <simpara>If you've configured a web server that isn't listed here for gitweb, please send
\r
615 in the instructions so they can be included in a future release.</simpara>
\r
616 <section id="gitweb(1)__apache_as_cgi">
\r
617 <title>Apache as CGI</title>
\r
618 <simpara>Apache must be configured to support CGI scripts in the directory in
\r
619 which gitweb is installed. Let's assume that it is <emphasis>/var/www/cgi-bin</emphasis>
\r
620 directory.</simpara>
\r
621 <screen>ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
\r
623 <Directory "/var/www/cgi-bin">
\r
624 Options Indexes FollowSymlinks ExecCGI
\r
628 </Directory></screen>
\r
629 <simpara>With that configuration the full path to browse repositories would be:</simpara>
\r
630 <literallayout class="monospaced">http://server/cgi-bin/gitweb.cgi</literallayout>
\r
632 <section id="gitweb(1)__apache_with_mod_perl_via_modperl_registry">
\r
633 <title>Apache with mod_perl, via ModPerl::Registry</title>
\r
634 <simpara>You can use mod_perl with gitweb. You must install Apache::Registry
\r
635 (for mod_perl 1.x) or ModPerl::Registry (for mod_perl 2.x) to enable
\r
636 this support.</simpara>
\r
637 <simpara>Assuming that gitweb is installed to <emphasis>/var/www/perl</emphasis>, the following
\r
638 Apache configuration (for mod_perl 2.x) is suitable.</simpara>
\r
639 <screen>Alias /perl "/var/www/perl"
\r
641 <Directory "/var/www/perl">
\r
642 SetHandler perl-script
\r
643 PerlResponseHandler ModPerl::Registry
\r
644 PerlOptions +ParseHeaders
\r
645 Options Indexes FollowSymlinks +ExecCGI
\r
649 </Directory></screen>
\r
650 <simpara>With that configuration the full path to browse repositories would be:</simpara>
\r
651 <literallayout class="monospaced">http://server/perl/gitweb.cgi</literallayout>
\r
653 <section id="gitweb(1)__apache_with_fastcgi">
\r
654 <title>Apache with FastCGI</title>
\r
655 <simpara>Gitweb works with Apache and FastCGI. First you need to rename, copy
\r
656 or symlink gitweb.cgi to gitweb.fcgi. Let's assume that gitweb is
\r
657 installed in <emphasis>/usr/share/gitweb</emphasis> directory. The following Apache
\r
658 configuration is suitable (UNTESTED!)</simpara>
\r
659 <screen>FastCgiServer /usr/share/gitweb/gitweb.cgi
\r
660 ScriptAlias /gitweb /usr/share/gitweb/gitweb.cgi
\r
662 Alias /gitweb/static /usr/share/gitweb/static
\r
663 <Directory /usr/share/gitweb/static>
\r
664 SetHandler default-handler
\r
665 </Directory></screen>
\r
666 <simpara>With that configuration the full path to browse repositories would be:</simpara>
\r
667 <literallayout class="monospaced">http://server/gitweb</literallayout>
\r
670 <simplesect id="gitweb(1)__advanced_web_server_setup">
\r
671 <title>ADVANCED WEB SERVER SETUP</title>
\r
672 <simpara>All of those examples use request rewriting, and need <emphasis>mod_rewrite</emphasis>
\r
673 (or equivalent; examples below are written for Apache).</simpara>
\r
674 <section id="gitweb(1)__single_url_for_gitweb_and_for_fetching">
\r
675 <title>Single URL for gitweb and for fetching</title>
\r
676 <simpara>If you want to have one URL for both gitweb and your <emphasis>http://</emphasis>
\r
677 repositories, you can configure Apache like this:</simpara>
\r
678 <screen><VirtualHost *:80>
\r
679 ServerName git.example.org
\r
680 DocumentRoot /pub/git
\r
681 SetEnv GITWEB_CONFIG /etc/gitweb.conf
\r
683 # turning on mod rewrite
\r
686 # make the front page an internal rewrite to the gitweb script
\r
687 RewriteRule ^/$ /cgi-bin/gitweb.cgi
\r
689 # make access for "dumb clients" work
\r
690 RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ \
\r
691 /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
\r
692 </VirtualHost></screen>
\r
693 <simpara>The above configuration expects your public repositories to live under
\r
694 <emphasis>/pub/git</emphasis> and will serve them as <emphasis>http://git.domain.org/dir-under-pub-git</emphasis>,
\r
695 both as cloneable GIT URL and as browseable gitweb interface. If you then
\r
696 start your <xref linkend="git-daemon(1)" /> with <emphasis>--base-path=/pub/git --export-all</emphasis>
\r
697 then you can even use the <emphasis>git://</emphasis> URL with exactly the same path.</simpara>
\r
698 <simpara>Setting the environment variable <emphasis>GITWEB_CONFIG</emphasis> will tell gitweb to use the
\r
699 named file (i.e. in this example <emphasis>/etc/gitweb.conf</emphasis>) as a configuration for
\r
700 gitweb. You don't really need it in above example; it is required only if
\r
701 your configuration file is in different place than built-in (during
\r
702 compiling gitweb) <emphasis>gitweb_config.perl</emphasis> or <emphasis>/etc/gitweb.conf</emphasis>. See
\r
703 <xref linkend="gitweb.conf(5)" /> for details, especially information about precedence
\r
705 <simpara>If you use the rewrite rules from the example you <emphasis role="strong">might</emphasis> also need
\r
706 something like the following in your gitweb configuration file
\r
707 (<emphasis>/etc/gitweb.conf</emphasis> following example):</simpara>
\r
708 <screen>@stylesheets = ("/some/absolute/path/gitweb.css");
\r
711 $per_request_config = 1;</screen>
\r
712 <simpara>Nowadays though gitweb should create HTML base tag when needed (to set base
\r
713 URI for relative links), so it should work automatically.</simpara>
\r
715 <section id="gitweb(1)__webserver_configuration_with_multiple_projects_root">
\r
716 <title>Webserver configuration with multiple projects' root</title>
\r
717 <simpara>If you want to use gitweb with several project roots you can edit your
\r
718 Apache virtual host and gitweb configuration files in the following way.</simpara>
\r
719 <simpara>The virtual host configuration (in Apache configuration file) should look
\r
720 like this:</simpara>
\r
721 <screen><VirtualHost *:80>
\r
722 ServerName git.example.org
\r
723 DocumentRoot /pub/git
\r
724 SetEnv GITWEB_CONFIG /etc/gitweb.conf
\r
726 # turning on mod rewrite
\r
729 # make the front page an internal rewrite to the gitweb script
\r
730 RewriteRule ^/$ /cgi-bin/gitweb.cgi [QSA,L,PT]
\r
732 # look for a public_git folder in unix users' home
\r
733 # http://git.example.org/~<user>/
\r
734 RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
\r
735 [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
\r
737 # http://git.example.org/+<user>/
\r
738 #RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
\r
739 [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
\r
741 # http://git.example.org/user/<user>/
\r
742 #RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
\r
743 [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
\r
745 # defined list of project roots
\r
746 RewriteRule ^/scm(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
\r
747 [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT]
\r
748 RewriteRule ^/var(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \
\r
749 [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT]
\r
751 # make access for "dumb clients" work
\r
752 RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ \
\r
753 /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
\r
754 </VirtualHost></screen>
\r
755 <simpara>Here actual project root is passed to gitweb via <emphasis>GITWEB_PROJECT_ROOT</emphasis>
\r
756 environment variable from a web server, so you need to put the following
\r
757 line in gitweb configuration file (<emphasis>/etc/gitweb.conf</emphasis> in above example):</simpara>
\r
758 <screen>$projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git";</screen>
\r
759 <simpara><emphasis role="strong">Note</emphasis> that this requires to be set for each request, so either
\r
760 <emphasis>$per_request_config</emphasis> must be false, or the above must be put in code
\r
761 referenced by <emphasis>$per_request_config</emphasis>;</simpara>
\r
762 <simpara>These configurations enable two things. First, each unix user (<emphasis><user></emphasis>) of
\r
763 the server will be able to browse through gitweb git repositories found in
\r
764 <emphasis>~/public_git/</emphasis> with the following url:</simpara>
\r
765 <literallayout class="monospaced">http://git.example.org/~<user>/</literallayout>
\r
766 <simpara>If you do not want this feature on your server just remove the second
\r
767 rewrite rule.</simpara>
\r
768 <simpara>If you already use mod_userdir` in your virtual host or you don't want to
\r
769 use the '~ as first character, just comment or remove the second rewrite
\r
770 rule, and uncomment one of the following according to what you want.</simpara>
\r
771 <simpara>Second, repositories found in <emphasis>/pub/scm/</emphasis> and <emphasis>/var/git/</emphasis> will be accessible
\r
772 through <emphasis>http://git.example.org/scm/</emphasis> and <emphasis>http://git.example.org/var/</emphasis>.
\r
773 You can add as many project roots as you want by adding rewrite rules like
\r
774 the third and the fourth.</simpara>
\r
776 <section id="gitweb(1)__path_info_usage">
\r
777 <title>PATH_INFO usage</title>
\r
778 <simpara>If you enable PATH_INFO usage in gitweb by putting</simpara>
\r
779 <screen>$feature{'pathinfo'}{'default'} = [1];</screen>
\r
780 <simpara>in your gitweb configuration file, it is possible to set up your server so
\r
781 that it consumes and produces URLs in the form</simpara>
\r
782 <literallayout class="monospaced">http://git.example.com/project.git/shortlog/sometag</literallayout>
\r
783 <simpara>i.e. without <emphasis>gitweb.cgi</emphasis> part, by using a configuration such as the
\r
784 following. This configuration assumes that <emphasis>/var/www/gitweb</emphasis> is the
\r
785 DocumentRoot of your webserver, contains the gitweb.cgi script and
\r
786 complementary static files (stylesheet, favicon, JavaScript):</simpara>
\r
787 <screen><VirtualHost *:80>
\r
788 ServerAlias git.example.com
\r
790 DocumentRoot /var/www/gitweb
\r
792 <Directory /var/www/gitweb>
\r
794 AddHandler cgi-script cgi
\r
796 DirectoryIndex gitweb.cgi
\r
799 RewriteCond %{REQUEST_FILENAME} !-f
\r
800 RewriteCond %{REQUEST_FILENAME} !-d
\r
801 RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
\r
803 </VirtualHost></screen>
\r
804 <simpara>The rewrite rule guarantees that existing static files will be properly
\r
805 served, whereas any other URL will be passed to gitweb as PATH_INFO
\r
806 parameter.</simpara>
\r
807 <simpara><emphasis role="strong">Notice</emphasis> that in this case you don't need special settings for
\r
808 <emphasis>@stylesheets</emphasis>, <emphasis>$my_uri</emphasis> and <emphasis>$home_link</emphasis>, but you lose "dumb client"
\r
809 access to your project .git dirs (described in "Single URL for gitweb and
\r
810 for fetching" section). A possible workaround for the latter is the
\r
811 following: in your project root dir (e.g. <emphasis>/pub/git</emphasis>) have the projects
\r
812 named <emphasis role="strong">without</emphasis> a .git extension (e.g. <emphasis>/pub/git/project</emphasis> instead of
\r
813 <emphasis>/pub/git/project.git</emphasis>) and configure Apache as follows:</simpara>
\r
814 <screen><VirtualHost *:80>
\r
815 ServerAlias git.example.com
\r
817 DocumentRoot /var/www/gitweb
\r
819 AliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3
\r
820 <Directory /var/www/gitweb>
\r
822 AddHandler cgi-script cgi
\r
824 DirectoryIndex gitweb.cgi
\r
827 RewriteCond %{REQUEST_FILENAME} !-f
\r
828 RewriteCond %{REQUEST_FILENAME} !-d
\r
829 RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
\r
831 </VirtualHost></screen>
\r
832 <simpara>The additional AliasMatch makes it so that</simpara>
\r
833 <literallayout class="monospaced">http://git.example.com/project.git</literallayout>
\r
834 <simpara>will give raw access to the project's git dir (so that the project can be
\r
835 cloned), while</simpara>
\r
836 <literallayout class="monospaced">http://git.example.com/project</literallayout>
\r
837 <simpara>will provide human-friendly gitweb access.</simpara>
\r
838 <simpara>This solution is not 100% bulletproof, in the sense that if some project has
\r
839 a named ref (branch, tag) starting with <emphasis>git/</emphasis>, then paths such as</simpara>
\r
840 <literallayout class="monospaced">http://git.example.com/project/command/abranch..git/abranch</literallayout>
\r
841 <simpara>will fail with a 404 error.</simpara>
\r
844 <simplesect id="gitweb(1)__bugs">
\r
845 <title>BUGS</title>
\r
846 <simpara>Please report any bugs or feature requests to <ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>,
\r
847 putting "gitweb" in the subject of email.</simpara>
\r
849 <simplesect id="gitweb(1)__see_also">
\r
850 <title>SEE ALSO</title>
\r
851 <simpara><xref linkend="gitweb.conf(5)" />, <xref linkend="git-instaweb(1)" /></simpara>
\r
852 <simpara><emphasis>gitweb/README</emphasis>, <emphasis>gitweb/INSTALL</emphasis></simpara>
\r
854 <simplesect id="gitweb(1)__git">
\r
856 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r