blob: 51d8c3cdc1979daf52be18f617a7dc31f58f0eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 || :