README (4494B)
1stagit
2------
34
static git page generator.
56
It generates static HTML pages for a git repository.
78
9
Usage
10-----
1112
Make files per repository:
1314
$ mkdir -p htmlroot/htmlrepo1 && cd htmlroot/htmlrepo1
15$ stagit path/to/gitrepo1
16repeat for other repositories
17$ ...
1819
Make index file for repositories:
2021
$ cd htmlroot
22$ stagit-index path/to/gitrepo1 \
23path/to/gitrepo2 \
24path/to/gitrepo3 > index.html
2526
27
Build and install
28-----------------
2930
$ make
31# make install
3233
34
Dependencies
35------------
3637
- C compiler (C99).
38- libc (tested with OpenBSD, FreeBSD, NetBSD, Linux: glibc and musl).
39- libgit2 (v0.22+).
40- POSIX make (optional).
4142
43
Documentation
44-------------
4546
See man pages: stagit(1) and stagit-index(1).
4748
49
Building a static binary
50------------------------
5152
It may be useful to build static binaries, for example to run in a chroot.
5354
It can be done like this at the time of writing (v0.24):
5556
cd libgit2-src
5758
# change the options in the CMake file: CMakeLists.txt
59BUILD_SHARED_LIBS to OFF (static)
60CURL to OFF (not needed)
61USE_SSH OFF (not needed)
62THREADSAFE OFF (not needed)
63USE_OPENSSL OFF (not needed, use builtin)
6465
mkdir -p build && cd build
66cmake ../
67make
68make install
6970
71
Extract owner field from git config
72-----------------------------------
7374
A way to extract the gitweb owner for example in the format:
7576
[gitweb]
77owner = Name here
7879
Script:
8081
#!/bin/sh
82awk '/^[ ]*owner[ ]=/ {
83sub(/^[^=]*=[ ]*/, "");
84print $0;
85}'
8687
88
Set clone URL for a directory of repos
89--------------------------------------
90#!/bin/sh
91cd "$dir"
92for i in *; do
93test -d "$i" && echo "git://git.codemadness.org/$i" > "$i/url"
94done
9596
97
Update files on git push
98------------------------
99100
Using a post-receive hook the static files can be automatically updated.
101Keep in mind git push -f can change the history and the commits may need
102to be recreated. This is because stagit checks if a commit file already
103exists. It also has a cache (-c) option which can conflict with the new
104history. See stagit(1).
105106
git post-receive hook (repo/.git/hooks/post-receive):
107108
#!/bin/sh
109# detect git push -f
110force=0
111while read -r old new ref; do
112hasrevs=$(git rev-list "$old" "^$new" | sed 1q)
113if test -n "$hasrevs"; then
114force=1
115break
116fi
117done
118119
# remove commits and .cache on git push -f
120#if test "$force" = "1"; then
121# ...
122#fi
123124
# see example_create.sh for normal creation of the files.
125126
127
Create .tar.gz archives by tag
128------------------------------
129#!/bin/sh
130name="stagit"
131mkdir -p archives
132git tag -l | while read -r t; do
133f="archives/${name}-$(echo "${t}" | tr '/' '_').tar.gz"
134test -f "${f}" && continue
135git archive \
136--format tar.gz \
137--prefix "${t}/" \
138-o "${f}" \
139-- \
140"${t}"
141done
142143
144
Features
145--------
146147
- Log of all commits from HEAD.
148- Log and diffstat per commit.
149- Show file tree with linkable line numbers.
150- Show references: local branches and tags.
151- Detect README and LICENSE file from HEAD and link it as a webpage.
152- Detect submodules (.gitmodules file) from HEAD and link it as a webpage.
153- Atom feed of the commit log (atom.xml).
154- Atom feed of the tags/refs (tags.xml).
155- Make index page for multiple repositories with stagit-index.
156- After generating the pages (relatively slow) serving the files is very fast,
157simple and requires little resources (because the content is static), only
158a HTTP file server is required.
159- Usable with text-browsers such as dillo, links, lynx and w3m.
160161
162
Cons
163----
164165
- Not suitable for large repositories (2000+ commits), because diffstats are
166an expensive operation, the cache (-c flag) is a workaround for this in
167some cases.
168- Not suitable for large repositories with many files, because all files are
169written for each execution of stagit. This is because stagit shows the lines
170of textfiles and there is no "cache" for file metadata (this would add more
171complexity to the code).
172- Not suitable for repositories with many branches, a quite linear history is
173assumed (from HEAD).
174175
In these cases it is better to just use cgit or possibly change stagit to
176run as a CGI program.
177178
- Relatively slow to run the first time (about 3 seconds for sbase,
1791500+ commits), incremental updates are faster.
180- Does not support some of the dynamic features cgit has, like:
181- Snapshot tarballs per commit.
182- File tree per commit.
183- History log of branches diverged from HEAD.
184- Stats (git shortlog -s).
185186
This is by design, just use git locally.