Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep the commit-graph current in an example hook
cgit's log, blame and graph pages read commits from the commit-graph
when a repository has one, and its changed path filters let a walk
limited to one file skip the commits that never touched it. git gc
writes a graph only now and then and starts those filters only when a
write asks for them, so the hook writes a split layer with them after
each push.
Diffstat (limited to 'custom/hooks')
| -rwxr-xr-x | custom/hooks/post-receive.commit-graph | 34 |
1 file changed, 34 insertions, 0 deletions
diff --git a/custom/hooks/post-receive.commit-graph b/custom/hooks/post-receive.commit-graph new file mode 100755 index 0000000..51d8c3c --- /dev/null +++ b/custom/hooks/post-receive.commit-graph @@ -0,0 +1,34 @@ +#!/bin/sh + +# Brings the repository's commit-graph up to date after a push. cgit's log, +# blame and graph pages then read commits from it instead of parsing each one +# out of the object store, and its changed path filters let a log or blame of +# one file skip the commits that never touched it. git gc writes a graph now +# and then, but starts the filters only when one is written with them, as this +# does, and keeps them from then on. +# +# --split writes each push's new commits as a small layer over the last, and +# git merges the layers as they pile up, so a push costs little. A git too old +# for these options leaves the graph as it was, and nothing here complains or +# exits nonzero, so the pusher is not shown an error over a missing speedup. +# +# To install the hook, copy or link it to hooks/post-receive in each +# repository. Git runs one post-receive per repository, so fold this together +# with the other hooks here to have more than one. + +set -eu + +# The pushing user's umask decides the mode of a new graph file in a +# repository git does not share, so force one that leaves it readable by the +# web server. git writes a shared repository's files group writable itself. +case "$(git config --get core.sharedRepository | tr '[:upper:]' '[:lower:]')" in +""|umask|0|false|no|off) + umask 022 + ;; +*) + umask 002 + ;; +esac + +git commit-graph write --reachable --split --changed-paths --no-progress \ + >/dev/null 2>&1 || : |
