#!/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 || :