098dc16fab385ae83c279c5169d7d79dc14387fe
[git-central.git] / server / update-lock-check
1 #!/bin/sh
2
3 #
4 # Checks $GIT_DIR/locked and $GIT_DIR/preserved for branches that cannot be
5 # touched.
6 #
7
8 . $(dirname $0)/functions
9
10 refname=$1
11 oldrev=$2
12 newrev=$3
13
14 # We only care about branches
15 case "$refname" in
16         refs/heads/*)
17                 short_refname=${refname##refs/heads/}
18                 ;;
19         *)
20                 exit 0
21                 ;;
22 esac
23
24 if test -f "$GIT_DIR/locked" ; then
25         grep $short_refname "$GIT_DIR/locked"
26         if [ $? -eq 0 ] ; then
27                 display_error_message "Branch $short_refname is locked"
28                 exit 1
29         fi
30 fi
31
32 if test -f "$GIT_DIR/preserved" ; then
33         grep $short_refname "$GIT_DIR/preserved"
34         if [ $? -eq 0 ] ; then
35                 display_error_message "Branch $short_refname cannot be deleted"
36                 exit 1
37         fi
38 fi
39