| | #!/bin/sh |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | refname="$1" |
| | oldrev="$2" |
| | newrev="$3" |
| |
|
| | |
| | if [ -z "$GIT_DIR" ]; then |
| | echo "Don't run this script from the command line." >&2 |
| | echo " (if you want, you could supply GIT_DIR then run" >&2 |
| | echo " $0 <ref> <oldrev> <newrev>)" >&2 |
| | exit 1 |
| | fi |
| |
|
| | if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then |
| | echo "usage: $0 <ref> <oldrev> <newrev>" >&2 |
| | exit 1 |
| | fi |
| |
|
| | |
| | allowunannotated=$(git config --type=bool hooks.allowunannotated) |
| | allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch) |
| | denycreatebranch=$(git config --type=bool hooks.denycreatebranch) |
| | allowdeletetag=$(git config --type=bool hooks.allowdeletetag) |
| | allowmodifytag=$(git config --type=bool hooks.allowmodifytag) |
| |
|
| | |
| | projectdesc=$(sed -e '1q' "$GIT_DIR/description") |
| | case "$projectdesc" in |
| | "Unnamed repository"* | "") |
| | echo "*** Project description file hasn't been set" >&2 |
| | exit 1 |
| | ;; |
| | esac |
| |
|
| | |
| | |
| | zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0') |
| | if [ "$newrev" = "$zero" ]; then |
| | newrev_type=delete |
| | else |
| | newrev_type=$(git cat-file -t $newrev) |
| | fi |
| |
|
| | case "$refname","$newrev_type" in |
| | refs/tags/*,commit) |
| | |
| | short_refname=${refname##refs/tags/} |
| | if [ "$allowunannotated" != "true" ]; then |
| | echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 |
| | echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 |
| | exit 1 |
| | fi |
| | ;; |
| | refs/tags/*,delete) |
| | |
| | if [ "$allowdeletetag" != "true" ]; then |
| | echo "*** Deleting a tag is not allowed in this repository" >&2 |
| | exit 1 |
| | fi |
| | ;; |
| | refs/tags/*,tag) |
| | |
| | if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 |
| | then |
| | echo "*** Tag '$refname' already exists." >&2 |
| | echo "*** Modifying a tag is not allowed in this repository." >&2 |
| | exit 1 |
| | fi |
| | ;; |
| | refs/heads/*,commit) |
| | |
| | if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then |
| | echo "*** Creating a branch is not allowed in this repository" >&2 |
| | exit 1 |
| | fi |
| | ;; |
| | refs/heads/*,delete) |
| | |
| | if [ "$allowdeletebranch" != "true" ]; then |
| | echo "*** Deleting a branch is not allowed in this repository" >&2 |
| | exit 1 |
| | fi |
| | ;; |
| | refs/remotes/*,commit) |
| | |
| | ;; |
| | refs/remotes/*,delete) |
| | |
| | if [ "$allowdeletebranch" != "true" ]; then |
| | echo "*** Deleting a tracking branch is not allowed in this repository" >&2 |
| | exit 1 |
| | fi |
| | ;; |
| | *) |
| | |
| | echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 |
| | exit 1 |
| | ;; |
| | esac |
| |
|
| | |
| | exit 0 |
| |
|