Teach "fsck" not to follow subproject links
[git/jrn.git] / templates / hooks--update
blob0ff03309e69aed6b506e333e087f23099ad80290
1 #!/bin/sh
3 # An example hook script to blocks unannotated tags from entering.
4 # Called by git-receive-pack with arguments: refname sha1-old sha1-new
6 # To enable this hook, make this file executable by "chmod +x update".
8 # Config
9 # ------
10 # hooks.allowunannotated
11 # This boolean sets whether unannotated tags will be allowed into the
12 # repository. By default they won't be.
15 # --- Command line
16 refname="$1"
17 oldrev="$2"
18 newrev="$3"
20 # --- Safety check
21 if [ -z "$GIT_DIR" ]; then
22 echo "Don't run this script from the command line." >&2
23 echo " (if you want, you could supply GIT_DIR then run" >&2
24 echo " $0 <ref> <oldrev> <newrev>)" >&2
25 exit 1
28 if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
29 echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
30 exit 1
33 # --- Config
34 allowunannotated=$(git-repo-config --bool hooks.allowunannotated)
36 # check for no description
37 if [ -z "$projectdesc" -o "$projectdesc" = "Unnamed repository; edit this file to name it for gitweb" ]; then
38 echo "*** Project description file hasn't been set" >&2
39 exit 1
42 # --- Check types
43 newrev_type=$(git-cat-file -t $newrev)
45 case "$refname","$newrev_type" in
46 refs/tags/*,commit)
47 # un-annotated tag
48 short_refname=${refname##refs/tags/}
49 if [ "$allowunannotated" != "true" ]; then
50 echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
51 echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
52 exit 1
55 refs/tags/*,tag)
56 # annotated tag
58 refs/heads/*,commit)
59 # branch
61 refs/remotes/*,commit)
62 # tracking branch
65 # Anything else (is there anything else?)
66 echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
67 exit 1
69 esac
71 # --- Finished
72 exit 0