petal
petal is a CGI program that shows bare git repositories: an index, log, tree, raw files, commits with diffs, and refs.
Requirements
- libgit2 and its header files
Installation
cd petal
make clean install
Usage
Run petal as a CGI program, for example with nginx and fcgiwrap, and serve
style.css and icon.svg from share/petal. petal sets no resource
limits itself, so run it through a wrapper:
#!/bin/sh
ulimit -t 10
exec /usr/local/bin/petal
nginx:
location = /style.css { alias /usr/local/share/petal/style.css; }
location = /icon.svg { alias /usr/local/share/petal/icon.svg; }
location / {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/bin/petal-cgi;
fastcgi_param SCRIPT_NAME "";
fastcgi_param PATH_INFO $uri;
fastcgi_pass unix:/run/fcgiwrap.sock;
}
libgit2 refuses repositories owned by another user unless they are listed
as safe.directory in $HOME/.gitconfig.
Repositories
A directory root/name.git is the repository name. Names may be nested,
such as group/repo, up to maxdepth levels. Only repositories containing
git-daemon-export-ok are shown.
descriptionone line describing the repositoryownerone line naming the ownergit-daemon-export-okpresent if the repository is public
Pages
The page comes from PATH_INFO: the longest prefix naming a repository is
the repository, the rest is the page. A ref is a branch, a tag or a
commit id of 4 to 40 hex digits; without one, HEAD is used.
| path | page |
|---|---|
/ |
all repositories, with description, owner and age |
/repo, /repo/log[/ref] |
log, loglimit commits per page, older pages with ?ofs=n |
/repo/tree[/ref[/path]] |
directory listing or file with line anchors |
/repo/raw/ref/path |
the file as is, text/plain or application/octet-stream |
/repo/commit/id |
commit, diffstat and diff, cut after maxdiff lines |
/repo/refs |
branches and tags |
Every response carries a Content-Security-Policy that only allows the stylesheet and icon from the same origin.
Configuration
| setting | default | meaning |
|---|---|---|
root |
/srv/git |
directory of bare repositories |
css |
/style.css |
stylesheet URL |
icon |
/icon.svg |
icon URL |
clone |
git@git.lostduk.com: |
prefix of the git clone line on repository pages |
title |
greenhouse |
name in the top bar and on the index |
service |
git |
which entry of services is this one |
services |
git, lists | links in the top bar to the other services |
loglimit |
100 |
commits per log page |
maxdepth |
8 |
nesting levels of repository names |
barwidth |
40 |
width of the diffstat bars, in characters |
maxblob |
512 * 1024 |
largest file shown, in bytes |
maxdiff |
10000 |
diff lines shown per commit |