summaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
Diffstat (limited to 'gitweb')
-rw-r--r--gitweb/INSTALL225
-rw-r--r--gitweb/gitweb.css2
-rwxr-xr-xgitweb/gitweb.perl127
3 files changed, 302 insertions, 52 deletions
diff --git a/gitweb/INSTALL b/gitweb/INSTALL
new file mode 100644
index 0000000..6328e26
--- /dev/null
+++ b/gitweb/INSTALL
@@ -0,0 +1,225 @@
+GIT web Interface (gitweb) Installation
+=======================================
+
+First you have to generate gitweb.cgi from gitweb.perl using
+"make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi,
+gitweb.css, git-logo.png and git-favicon.png) to their destination.
+For example if git was (or is) installed with /usr prefix, you can do
+
+ $ make prefix=/usr gitweb/gitweb.cgi ;# as yourself
+ # cp gitweb/git* /var/www/cgi-bin/ ;# as root
+
+Alternatively you can use autoconf generated ./configure script to
+set up path to git binaries (via config.mak.autogen), so you can write
+instead
+
+ $ make configure ;# as yourself
+ $ ./configure --prefix=/usr ;# as yourself
+ $ make gitweb/gitweb.cgi ;# as yourself
+ # cp gitweb/git* /var/www/cgi-bin/ ;# as root
+
+The above example assumes that your web server is configured to run
+[executable] files in /var/www/cgi-bin/ as server scripts (as CGI
+scripts).
+
+
+Build time configuration
+------------------------
+
+See also "How to configure gitweb for your local system" in README
+file for gitweb (in gitweb/README).
+
+- There are many configuration variables which affects building of
+ gitweb.cgi; see "default configuration for gitweb" section in main
+ (top dir) Makefile, and instructions for building gitweb/gitweb.cgi
+ target.
+
+ One of most important is where to find git wrapper binary. Gitweb
+ tries to find git wrapper at $(bindir)/git, so you have to set $bindir
+ when building gitweb.cgi, or $prefix from which $bindir is derived. If
+ you build and install gitweb together with the rest of git suite,
+ there should be no problems. Otherwise, if git was for example
+ installed from a binary package, you have to set $prefix (or $bindir)
+ accordingly.
+
+- Another important issue is where are git repositories you want to make
+ available to gitweb. By default gitweb search for repositories under
+ /pub/git; if you want to have projects somewhere else, like /home/git,
+ use GITWEB_PROJECTROOT build configuration variable.
+
+ By default all git repositories under projectroot are visible and
+ available to gitweb. List of projects is generated by default by
+ scanning the projectroot directory for git repositories. This can be
+ changed (configured) as described in "Gitweb repositories" section
+ below.
+
+ Note that gitweb deals directly with object database, and does not
+ need working directory; the name of the project is the name of its
+ repository object database, usually projectname.git for bare
+ repositories. If you want to provide gitweb access to non-bare (live)
+ repository, you can make projectname.git symbolic link under
+ projectroot linking to projectname/.git (but it is just
+ a suggestion).
+
+- You can control where gitweb tries to find its main CSS style file,
+ its favicon and logo with GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
+ build configuration variables. By default gitweb tries to find them
+ in the same directory as gitweb.cgi script.
+
+Build example
+~~~~~~~~~~~~~
+
+- To install gitweb to /var/www/cgi-bin/gitweb/ when git wrapper
+ is installed at /usr/local/bin/git and the repositories (projects)
+ we want to display are under /home/local/scm, you can do
+
+ make GITWEB_PROJECTROOT="/home/local/scm" \
+ GITWEB_CSS="/gitweb/gitweb.css" \
+ GITWEB_LOGO="/gitweb/git-logo.png" \
+ GITWEB_FAVICON="/gitweb/git-favicon.png" \
+ bindir=/usr/local/bin \
+ gitweb/gitweb.cgi
+
+ cp -fv ~/git/gitweb/gitweb.{cgi,css} \
+ ~/git/gitweb/git-{favicon,logo}.png \
+ /var/www/cgi-bin/gitweb/
+
+
+Gitweb config file
+------------------
+
+See also "Runtime gitweb configuration" section in README file
+for gitweb (in gitweb/README).
+
+- You can configure gitweb further using gitweb configuration file;
+ by default it is file named gitweb_config.perl in the same place as
+ gitweb.cgi script. You can control default place for config file
+ using GITWEB_CONFIG build configuration variable, and you can set it
+ using GITWEB_CONFIG environmental variable.
+
+- Gitweb config file is [fragment] of perl code. You can set variables
+ using "our $variable = value"; text from "#" character until the end
+ of a line is ignored. See perlsyn(1) for details.
+
+ See the top of gitweb.perl file for examples of customizable options.
+
+Config file example
+~~~~~~~~~~~~~~~~~~~
+
+To enable blame, pickaxe search, and snapshot support, while allowing
+individual projects to turn them off, put the following in your
+GITWEB_CONFIG file:
+
+ $feature{'blame'}{'default'} = [1];
+ $feature{'blame'}{'override'} = 1;
+
+ $feature{'pickaxe'}{'default'} = [1];
+ $feature{'pickaxe'}{'override'} = 1;
+
+ $feature{'snapshot'}{'default'} = ['x-gzip', 'gz', 'gzip'];
+ $feature{'snapshot'}{'override'} = 1;
+
+
+Gitweb repositories
+-------------------
+
+- By default all git repositories under projectroot are visible and
+ available to gitweb. List of projects is generated by default by
+ scanning the projectroot directory for git repositories (for object
+ databases to be more exact).
+
+ You can provide pre-generated list of [visible] repositories,
+ together with information about their owners (the project ownership
+ is taken from owner of repository directory otherwise), by setting
+ GITWEB_LIST build configuration variable (or $projects_list variable
+ in gitweb config file) to point to a plain file.
+
+ Each line of projects list file should consist of url-encoded path
+ to project repository database (relative to projectroot) separated
+ by space from url-encoded project owner; spaces in both project path
+ and project owner have to be encoded as either '%20' or '+'.
+
+ You can generate projects list index file using project_index action
+ (the 'TXT' link on projects list page) directly from gitweb.
+
+- By default even if project is not visible on projects list page, you
+ can view it nevertheless by hand-crafting gitweb URL. You can set
+ GITWEB_STRICT_EXPORT build configuration variable (or $strict_export
+ variable in gitweb config file) to only allow viewing of
+ repositories also shown on the overview page.
+
+- Alternatively, you can configure gitweb to only list and allow
+ viewing of the explicitly exported repositories, via
+ GITWEB_EXPORT_OK build configuration variable (or $export_ok
+ variable in gitweb config file). If it evaluates to true, gitweb
+ show repository only if this file exists in its object database
+ (if directory has the magic file $export_ok).
+
+Generating projects list using gitweb
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We assume that GITWEB_CONFIG has its default Makefile value, namely
+gitweb_config.perl. Put the following in gitweb_make_index.perl file:
+
+ $GITWEB_CONFIG = "gitweb_config.perl";
+ do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+
+ $projects_list = $projectroot;
+
+Then create the following script to get list of project in the format
+suitable for GITWEB_LIST build configuration variable (or
+$projects_list variable in gitweb config):
+
+ #!/bin/sh
+
+ export GITWEB_CONFIG="gitweb_make_index.perl"
+ export GATEWAY_INTERFACE="CGI/1.1"
+ export HTTP_ACCEPT="*/*"
+ export REQUEST_METHOD="GET"
+ export QUERY_STRING="a=project_index"
+
+ perl -- /var/www/cgi-bin/gitweb.cgi
+
+
+Requirements
+------------
+
+ - Core git tools
+ - Perl
+ - Perl modules: CGI, Encode, Fcntl, File::Find, File::Basename.
+ - web server
+
+
+Example web server configuration
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+See also "Webserver configuration" section in README file for gitweb
+(in gitweb/README).
+
+
+- Apache2, gitweb installed as CGI script,
+ under /var/www/cgi-bin/
+
+ ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
+
+ <Directory "/var/www/cgi-bin">
+ Options Indexes FollowSymlinks ExecCGI
+ AllowOverride None
+ Order allow,deny
+ Allow from all
+ </Directory>
+
+- Apache2, gitweb installed as mod_perl legacy script,
+ under /var/www/perl/
+
+ Alias /perl "/var/www/perl"
+
+ <Directory "/var/www/perl">
+ SetHandler perl-script
+ PerlResponseHandler ModPerl::Registry
+ PerlOptions +ParseHeaders
+ Options Indexes FollowSymlinks +ExecCGI
+ AllowOverride None
+ Order allow,deny
+ Allow from all
+ </Directory>
diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 7177c6e..5e40292 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -107,7 +107,7 @@ span.age {
font-style: italic;
}
-div.page_body span.signoff {
+span.signoff {
color: #888888;
}
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 27b5970..c48b35a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -19,7 +19,7 @@ use File::Basename qw(basename);
binmode STDOUT, ':utf8';
BEGIN {
- CGI->compile() if $ENV{MOD_PERL};
+ CGI->compile() if $ENV{'MOD_PERL'};
}
our $cgi = new CGI;
@@ -71,6 +71,10 @@ our $logo_label = "git homepage";
# source of projects list
our $projects_list = "++GITWEB_LIST++";
+# default order of projects list
+# valid values are none, project, descr, owner, and age
+our $default_projects_order = "project";
+
# show repository only if this file exists
# (only effective if this variable evaluates to true)
our $export_ok = "++GITWEB_EXPORT_OK++";
@@ -176,8 +180,8 @@ our %feature = (
# projects matching $projname/*.git will not be shown in the main
# projects list, instead a '+' mark will be added to $projname
# there and a 'forks' view will be enabled for the project, listing
- # all the forks. This feature is supported only if project list
- # is taken from a directory, not file.
+ # all the forks. If project list is taken from a file, forks have
+ # to be listed after the main project.
# To enable system wide have in $GITWEB_CONFIG
# $feature{'forks'}{'default'} = [1];
@@ -1047,6 +1051,8 @@ sub git_get_projects_list {
$filter ||= '';
$filter =~ s/\.git$//;
+ my ($check_forks) = gitweb_check_feature('forks');
+
if (-d $projects_list) {
# search in directory
my $dir = $projects_list . ($filter ? "/$filter" : '');
@@ -1054,8 +1060,6 @@ sub git_get_projects_list {
$dir =~ s!/+$!!;
my $pfxlen = length("$dir");
- my ($check_forks) = gitweb_check_feature('forks');
-
File::Find::find({
follow_fast => 1, # follow symbolic links
dangling_symlinks => 0, # ignore dangling symlinks, silently
@@ -1081,7 +1085,9 @@ sub git_get_projects_list {
# 'git%2Fgit.git Linus+Torvalds'
# 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
# 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
+ my %paths;
open my ($fd), $projects_list or return;
+ PROJECT:
while (my $line = <$fd>) {
chomp $line;
my ($path, $owner) = split ' ', $line;
@@ -1094,11 +1100,27 @@ sub git_get_projects_list {
# looking for forks;
my $pfx = substr($path, 0, length($filter));
if ($pfx ne $filter) {
- next;
+ next PROJECT;
}
my $sfx = substr($path, length($filter));
if ($sfx !~ /^\/.*\.git$/) {
- next;
+ next PROJECT;
+ }
+ } elsif ($check_forks) {
+ PATH:
+ foreach my $filter (keys %paths) {
+ # looking for forks;
+ my $pfx = substr($path, 0, length($filter));
+ if ($pfx ne $filter) {
+ next PATH;
+ }
+ my $sfx = substr($path, length($filter));
+ if ($sfx !~ /^\/.*\.git$/) {
+ next PATH;
+ }
+ # is a fork, don't include it in
+ # the list
+ next PROJECT;
}
}
if (check_export_ok("$projectroot/$path")) {
@@ -1106,12 +1128,13 @@ sub git_get_projects_list {
path => $path,
owner => to_utf8($owner),
};
- push @list, $pr
+ push @list, $pr;
+ (my $forks_path = $path) =~ s/\.git$//;
+ $paths{$forks_path}++;
}
}
close $fd;
}
- @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
return @list;
}
@@ -1800,7 +1823,7 @@ EOF
$cgi->hidden(-name => "a") . "\n" .
$cgi->hidden(-name => "h") . "\n" .
$cgi->popup_menu(-name => 'st', -default => 'commit',
- -values => ['commit', 'author', 'committer', 'pickaxe']) .
+ -values => ['commit', 'author', 'committer', 'pickaxe']) .
$cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) .
" search:\n",
$cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
@@ -1870,16 +1893,16 @@ sub git_print_page_nav {
my %arg = map { $_ => {action=>$_} } @navs;
if (defined $head) {
for (qw(commit commitdiff)) {
- $arg{$_}{hash} = $head;
+ $arg{$_}{'hash'} = $head;
}
if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
for (qw(shortlog log)) {
- $arg{$_}{hash} = $head;
+ $arg{$_}{'hash'} = $head;
}
}
}
- $arg{tree}{hash} = $treehead if defined $treehead;
- $arg{tree}{hash_base} = $treebase if defined $treebase;
+ $arg{'tree'}{'hash'} = $treehead if defined $treehead;
+ $arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
print "<div class=\"page_nav\">\n" .
(join " | ",
@@ -1927,9 +1950,9 @@ sub git_print_header_div {
my ($action, $title, $hash, $hash_base) = @_;
my %args = ();
- $args{action} = $action;
- $args{hash} = $hash if $hash;
- $args{hash_base} = $hash_base if $hash_base;
+ $args{'action'} = $action;
+ $args{'hash'} = $hash if $hash;
+ $args{'hash_base'} = $hash_base if $hash_base;
print "<div class=\"header\">\n" .
$cgi->a({-href => href(%args), -class => "title"},
@@ -2598,7 +2621,7 @@ sub git_project_list_body {
push @projects, $pr;
}
- $order ||= "project";
+ $order ||= $default_projects_order;
$from = 0 unless defined $from;
$to = $#projects if (!defined $to || $#projects < $to);
@@ -2957,7 +2980,7 @@ sub git_search_grep_body {
sub git_project_list {
my $order = $cgi->param('o');
- if (defined $order && $order !~ m/project|descr|owner|age/) {
+ if (defined $order && $order !~ m/none|project|descr|owner|age/) {
die_error(undef, "Unknown order parameter");
}
@@ -2980,7 +3003,7 @@ sub git_project_list {
sub git_forks {
my $order = $cgi->param('o');
- if (defined $order && $order !~ m/project|descr|owner|age/) {
+ if (defined $order && $order !~ m/none|project|descr|owner|age/) {
die_error(undef, "Unknown order parameter");
}
@@ -3095,7 +3118,7 @@ sub git_summary {
git_project_list_body(\@forklist, undef, 0, 15,
$#forklist <= 15 ? undef :
$cgi->a({-href => href(action=>"forks")}, "..."),
- 'noheader');
+ 'noheader');
}
git_footer_html();
@@ -3154,7 +3177,7 @@ sub git_blame2 {
}
$ftype = git_get_type($hash);
if ($ftype !~ "blob") {
- die_error("400 Bad Request", "Object is not a blob");
+ die_error('400 Bad Request', "Object is not a blob");
}
open ($fd, "-|", git_cmd(), "blame", '-p', '--',
$file_name, $hash_base)
@@ -3202,7 +3225,7 @@ HTML
my $rev = substr($full_rev, 0, 8);
my $author = $meta->{'author'};
my %date = parse_date($meta->{'author-time'},
- $meta->{'author-tz'});
+ $meta->{'author-tz'});
my $date = $date{'iso-tz'};
if ($group_size) {
$current_color = ++$current_color % $num_colors;
@@ -3214,24 +3237,24 @@ HTML
print " rowspan=\"$group_size\"" if ($group_size > 1);
print ">";
print $cgi->a({-href => href(action=>"commit",
- hash=>$full_rev,
- file_name=>$file_name)},
- esc_html($rev));
+ hash=>$full_rev,
+ file_name=>$file_name)},
+ esc_html($rev));
print "</td>\n";
}
open (my $dd, "-|", git_cmd(), "rev-parse", "$full_rev^")
- or die_error("could not open git-rev-parse");
+ or die_error(undef, "Open git-rev-parse failed");
my $parent_commit = <$dd>;
close $dd;
chomp($parent_commit);
my $blamed = href(action => 'blame',
- file_name => $meta->{'filename'},
- hash_base => $parent_commit);
+ file_name => $meta->{'filename'},
+ hash_base => $parent_commit);
print "<td class=\"linenr\">";
print $cgi->a({ -href => "$blamed#l$orig_lineno",
- -id => "l$lineno",
- -class => "linenr" },
- esc_html($lineno));
+ -id => "l$lineno",
+ -class => "linenr" },
+ esc_html($lineno));
print "</td>";
print "<td class=\"pre\">" . esc_html($data) . "</td>\n";
print "</tr>\n";
@@ -3621,8 +3644,8 @@ sub git_snapshot {
my $name = $project;
$name =~ s/\047/\047\\\047\047/g;
open my $fd, "-|",
- "$git archive --format=tar --prefix=\'$name\'/ $hash | $command"
- or die_error(undef, "Execute git-tar-tree failed.");
+ "$git archive --format=tar --prefix=\'$name\'/ $hash | $command"
+ or die_error(undef, "Execute git-tar-tree failed");
binmode STDOUT, ':raw';
print <$fd>;
binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
@@ -3719,7 +3742,7 @@ sub git_commit {
$formats_nav .=
'(merge: ' .
join(' ', map {
- $cgi->a({-href => href(action=>"commitdiff",
+ $cgi->a({-href => href(action=>"commit",
hash=>$_)},
esc_html(substr($_, 0, 7)));
} @$parents ) .
@@ -3734,7 +3757,7 @@ sub git_commit {
# difftree output is not printed for merges
open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
@diff_opts, $parent, $hash, "--"
- or die_error(undef, "Open git-diff-tree failed");
+ or die_error(undef, "Open git-diff-tree failed");
@difftree = map { chomp; $_ } <$fd>;
close $fd or die_error(undef, "Reading git-diff-tree failed");
}
@@ -3885,7 +3908,7 @@ sub git_blobdiff {
# read raw output
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
$hash_parent_base, $hash_base,
- "--", $file_name
+ "--", (defined $file_parent ? $file_parent : ()), $file_name
or die_error(undef, "Open git-diff-tree failed");
@difftree = map { chomp; $_ } <$fd>;
close $fd
@@ -3934,8 +3957,9 @@ sub git_blobdiff {
# open patch output
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
- '-p', $hash_parent_base, $hash_base,
- "--", $file_name
+ '-p', ($format eq 'html' ? "--full-index" : ()),
+ $hash_parent_base, $hash_base,
+ "--", (defined $file_parent ? $file_parent : ()), $file_name
or die_error(undef, "Open git-diff-tree failed");
}
@@ -3969,7 +3993,8 @@ sub git_blobdiff {
}
# open patch output
- open $fd, "-|", git_cmd(), "diff", '-p', @diff_opts,
+ open $fd, "-|", git_cmd(), "diff", @diff_opts,
+ '-p', ($format eq 'html' ? "--full-index" : ()),
$hash_parent, $hash, "--"
or die_error(undef, "Open git-diff failed");
} else {
@@ -4304,13 +4329,13 @@ sub git_search {
if ($page > 0) {
$paging_nav .=
$cgi->a({-href => href(action=>"search", hash=>$hash,
- searchtext=>$searchtext, searchtype=>$searchtype)},
- "first");
+ searchtext=>$searchtext, searchtype=>$searchtype)},
+ "first");
$paging_nav .= " &sdot; " .
$cgi->a({-href => href(action=>"search", hash=>$hash,
- searchtext=>$searchtext, searchtype=>$searchtype,
- page=>$page-1),
- -accesskey => "p", -title => "Alt-p"}, "prev");
+ searchtext=>$searchtext, searchtype=>$searchtype,
+ page=>$page-1),
+ -accesskey => "p", -title => "Alt-p"}, "prev");
} else {
$paging_nav .= "first";
$paging_nav .= " &sdot; prev";
@@ -4318,9 +4343,9 @@ sub git_search {
if ($#commitlist >= 100) {
$paging_nav .= " &sdot; " .
$cgi->a({-href => href(action=>"search", hash=>$hash,
- searchtext=>$searchtext, searchtype=>$searchtype,
- page=>$page+1),
- -accesskey => "n", -title => "Alt-n"}, "next");
+ searchtext=>$searchtext, searchtype=>$searchtype,
+ page=>$page+1),
+ -accesskey => "n", -title => "Alt-n"}, "next");
} else {
$paging_nav .= " &sdot; next";
}
@@ -4328,9 +4353,9 @@ sub git_search {
if ($#commitlist >= 100) {
$next_link =
$cgi->a({-href => href(action=>"search", hash=>$hash,
- searchtext=>$searchtext, searchtype=>$searchtype,
- page=>$page+1),
- -accesskey => "n", -title => "Alt-n"}, "next");
+ searchtext=>$searchtext, searchtype=>$searchtype,
+ page=>$page+1),
+ -accesskey => "n", -title => "Alt-n"}, "next");
}
git_print_page_nav('','', $hash,$co{'tree'},$hash, $paging_nav);