stagit

personal fork of static git page generator
git clone https://a3nm.net/git/stagit/
Log | Files | Refs | README | LICENSE

README (4348B)


      1 stagit
      2 ======
      3 
      4 WARNING: The official stagit page is there: https://git.2f30.org/stagit/
      5 This is just a mirror for my own use, you probably don't want to use this!
      6 
      7 static git page generator
      8 
      9 
     10 Usage
     11 -----
     12 
     13 Make files per repository:
     14 
     15 	$ mkdir -p htmldir && cd htmldir
     16 	$ stagit path-to-repo
     17 
     18 Make index file for repositories:
     19 
     20 	$ stagit-index repodir1 repodir2 repodir3 > index.html
     21 
     22 
     23 Install
     24 -------
     25 
     26 $ make
     27 # make install
     28 
     29 
     30 Dependencies
     31 ------------
     32 
     33 - libgit2 (v0.22+).
     34 - libc (tested with OpenBSD, FreeBSD, Linux: glibc and musl).
     35 - C compiler (C99).
     36 - make
     37 
     38 
     39 Documentation
     40 -------------
     41 
     42 See man pages: stagit(1) and stagit-index(1).
     43 
     44 
     45 Building a static binary
     46 ------------------------
     47 
     48 It may be useful to build static binaries, for example to run in a chroot.
     49 
     50 It can be done like this at the time of writing (v0.24):
     51 
     52 cd libgit2-src
     53 
     54 # change the options in the CMake file: CMakeLists.txt
     55 BUILD_SHARED_LIBS to OFF (static)
     56 CURL to OFF              (not needed)
     57 USE_SSH OFF              (not needed)
     58 THREADSAFE OFF           (not needed)
     59 USE_OPENSSL OFF          (not needed, use builtin)
     60 
     61 mkdir -p build && cd build
     62 cmake ../
     63 make
     64 make install
     65 
     66 
     67 Extract owner field from git config
     68 -----------------------------------
     69 
     70 A way to extract the gitweb owner for example in the format:
     71 
     72 	[gitweb]
     73 		owner = Name here
     74 
     75 Script:
     76 
     77 	#!/bin/sh
     78 	awk '/^[ 	]*owner[ 	]=/ {
     79 		sub(/^[^=]*=[ 	]*/, "");
     80 		print $0;
     81 	}'
     82 
     83 
     84 Set clone url for a directory of repos
     85 --------------------------------------
     86 	#!/bin/sh
     87 	cd "$dir"
     88 	for i in *; do
     89 		test -d "$i" && echo "git://git.codemadness.org/$i" > "$i/url"
     90 	done
     91 
     92 
     93 Update files on git push
     94 ------------------------
     95 
     96 Using a post-receive hook the static files can be automatically updated.
     97 Keep in mind git push -f can change the history and the commits may need
     98 to be recreated. This is because stagit checks if a commit file already
     99 exists. It also has a cache (-c) option which can conflict with the new
    100 history. See stagit(1).
    101 
    102 git post-receive hook (repo/.git/hooks/post-receive):
    103 
    104 	#!/bin/sh
    105 	# detect git push -f
    106 	force=0
    107 	while read -r old new ref; do
    108 		hasrevs=$(git rev-list "$old" "^$new" | sed 1q)
    109 		if test -n "$hasrevs"; then
    110 			force=1
    111 			break
    112 		fi
    113 	done
    114 
    115 	# remove commits and .cache on git push -f
    116 	#if test "$force" = "1"; then
    117 	# ...
    118 	#fi
    119 
    120 	# see example_create.sh for normal creation of the files.
    121 
    122 
    123 Create .tar.gz archives by tag
    124 ------------------------------
    125 	#!/bin/sh
    126 	name="stagit"
    127 	mkdir -p archives
    128 	git tag -l | while read -r t; do
    129 		f="archives/${name}-$(echo "${t}" | tr '/' '_').tar.gz"
    130 		test -f "${f}" && continue
    131 		git archive \
    132 			--format tar.gz \
    133 			--prefix "${t}/" \
    134 			-o "${f}" \
    135 			-- \
    136 			"${t}"
    137 	done
    138 
    139 
    140 Features
    141 --------
    142 
    143 - Log of all commits from HEAD.
    144 - Log and diffstat per commit.
    145 - Show file tree with linkable line numbers.
    146 - Show references: local branches and tags.
    147 - Detect README and LICENSE file from HEAD and link it as a webpage.
    148 - Detect submodules (.gitmodules file) from HEAD and link it as a webpage.
    149 - Atom feed log (atom.xml).
    150 - Make index page for multiple repositories with stagit-index.
    151 - After generating the pages (relatively slow) serving the files is very fast,
    152   simple and requires little resources (because the content is static), only
    153   a HTTP file server is required.
    154 - Usable with text-browsers such as dillo, links, lynx and w3m.
    155 
    156 
    157 Cons
    158 ----
    159 
    160 - Not suitable for large repositories (2000+ commits), because diffstats are
    161   an expensive operation, the cache (-c flag) is a workaround for this in
    162   some cases.
    163 - Not suitable for large repositories with many files, because all files are
    164   written for each execution of stagit. This is because stagit shows the lines
    165   of textfiles and there is no "cache" for file metadata (this would add more
    166   complexity to the code).
    167 - Not suitable for repositories with many branches, a quite linear history is
    168   assumed (from HEAD).
    169 
    170   In these cases it is better to just use cgit or possibly change stagit to
    171   run as a CGI program.
    172 
    173 - Relatively slow to run the first time (about 3 seconds for sbase,
    174   1500+ commits), incremental updates are faster.
    175 - Does not support some of the dynamic features cgit has, like:
    176   - Snapshot tarballs per commit.
    177   - File tree per commit.
    178   - History log of branches diverged from HEAD.
    179   - Stats (git shortlog -s).
    180 
    181   This is by design, just use git locally.