A metronome using the FRDM K64F board

Committer:
ram54288
Date:
Sun May 14 18:40:18 2017 +0000
Revision:
0:a7a43371b306
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:a7a43371b306 1 #!/bin/sh
ram54288 0:a7a43371b306 2 #
ram54288 0:a7a43371b306 3 # An example hook script to blocks unannotated tags from entering.
ram54288 0:a7a43371b306 4 # Called by "git receive-pack" with arguments: refname sha1-old sha1-new
ram54288 0:a7a43371b306 5 #
ram54288 0:a7a43371b306 6 # To enable this hook, rename this file to "update".
ram54288 0:a7a43371b306 7 #
ram54288 0:a7a43371b306 8 # Config
ram54288 0:a7a43371b306 9 # ------
ram54288 0:a7a43371b306 10 # hooks.allowunannotated
ram54288 0:a7a43371b306 11 # This boolean sets whether unannotated tags will be allowed into the
ram54288 0:a7a43371b306 12 # repository. By default they won't be.
ram54288 0:a7a43371b306 13 # hooks.allowdeletetag
ram54288 0:a7a43371b306 14 # This boolean sets whether deleting tags will be allowed in the
ram54288 0:a7a43371b306 15 # repository. By default they won't be.
ram54288 0:a7a43371b306 16 # hooks.allowmodifytag
ram54288 0:a7a43371b306 17 # This boolean sets whether a tag may be modified after creation. By default
ram54288 0:a7a43371b306 18 # it won't be.
ram54288 0:a7a43371b306 19 # hooks.allowdeletebranch
ram54288 0:a7a43371b306 20 # This boolean sets whether deleting branches will be allowed in the
ram54288 0:a7a43371b306 21 # repository. By default they won't be.
ram54288 0:a7a43371b306 22 # hooks.denycreatebranch
ram54288 0:a7a43371b306 23 # This boolean sets whether remotely creating branches will be denied
ram54288 0:a7a43371b306 24 # in the repository. By default this is allowed.
ram54288 0:a7a43371b306 25 #
ram54288 0:a7a43371b306 26
ram54288 0:a7a43371b306 27 # --- Command line
ram54288 0:a7a43371b306 28 refname="$1"
ram54288 0:a7a43371b306 29 oldrev="$2"
ram54288 0:a7a43371b306 30 newrev="$3"
ram54288 0:a7a43371b306 31
ram54288 0:a7a43371b306 32 # --- Safety check
ram54288 0:a7a43371b306 33 if [ -z "$GIT_DIR" ]; then
ram54288 0:a7a43371b306 34 echo "Don't run this script from the command line." >&2
ram54288 0:a7a43371b306 35 echo " (if you want, you could supply GIT_DIR then run" >&2
ram54288 0:a7a43371b306 36 echo " $0 <ref> <oldrev> <newrev>)" >&2
ram54288 0:a7a43371b306 37 exit 1
ram54288 0:a7a43371b306 38 fi
ram54288 0:a7a43371b306 39
ram54288 0:a7a43371b306 40 if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
ram54288 0:a7a43371b306 41 echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
ram54288 0:a7a43371b306 42 exit 1
ram54288 0:a7a43371b306 43 fi
ram54288 0:a7a43371b306 44
ram54288 0:a7a43371b306 45 # --- Config
ram54288 0:a7a43371b306 46 allowunannotated=$(git config --bool hooks.allowunannotated)
ram54288 0:a7a43371b306 47 allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
ram54288 0:a7a43371b306 48 denycreatebranch=$(git config --bool hooks.denycreatebranch)
ram54288 0:a7a43371b306 49 allowdeletetag=$(git config --bool hooks.allowdeletetag)
ram54288 0:a7a43371b306 50 allowmodifytag=$(git config --bool hooks.allowmodifytag)
ram54288 0:a7a43371b306 51
ram54288 0:a7a43371b306 52 # check for no description
ram54288 0:a7a43371b306 53 projectdesc=$(sed -e '1q' "$GIT_DIR/description")
ram54288 0:a7a43371b306 54 case "$projectdesc" in
ram54288 0:a7a43371b306 55 "Unnamed repository"* | "")
ram54288 0:a7a43371b306 56 echo "*** Project description file hasn't been set" >&2
ram54288 0:a7a43371b306 57 exit 1
ram54288 0:a7a43371b306 58 ;;
ram54288 0:a7a43371b306 59 esac
ram54288 0:a7a43371b306 60
ram54288 0:a7a43371b306 61 # --- Check types
ram54288 0:a7a43371b306 62 # if $newrev is 0000...0000, it's a commit to delete a ref.
ram54288 0:a7a43371b306 63 zero="0000000000000000000000000000000000000000"
ram54288 0:a7a43371b306 64 if [ "$newrev" = "$zero" ]; then
ram54288 0:a7a43371b306 65 newrev_type=delete
ram54288 0:a7a43371b306 66 else
ram54288 0:a7a43371b306 67 newrev_type=$(git cat-file -t $newrev)
ram54288 0:a7a43371b306 68 fi
ram54288 0:a7a43371b306 69
ram54288 0:a7a43371b306 70 case "$refname","$newrev_type" in
ram54288 0:a7a43371b306 71 refs/tags/*,commit)
ram54288 0:a7a43371b306 72 # un-annotated tag
ram54288 0:a7a43371b306 73 short_refname=${refname##refs/tags/}
ram54288 0:a7a43371b306 74 if [ "$allowunannotated" != "true" ]; then
ram54288 0:a7a43371b306 75 echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
ram54288 0:a7a43371b306 76 echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
ram54288 0:a7a43371b306 77 exit 1
ram54288 0:a7a43371b306 78 fi
ram54288 0:a7a43371b306 79 ;;
ram54288 0:a7a43371b306 80 refs/tags/*,delete)
ram54288 0:a7a43371b306 81 # delete tag
ram54288 0:a7a43371b306 82 if [ "$allowdeletetag" != "true" ]; then
ram54288 0:a7a43371b306 83 echo "*** Deleting a tag is not allowed in this repository" >&2
ram54288 0:a7a43371b306 84 exit 1
ram54288 0:a7a43371b306 85 fi
ram54288 0:a7a43371b306 86 ;;
ram54288 0:a7a43371b306 87 refs/tags/*,tag)
ram54288 0:a7a43371b306 88 # annotated tag
ram54288 0:a7a43371b306 89 if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
ram54288 0:a7a43371b306 90 then
ram54288 0:a7a43371b306 91 echo "*** Tag '$refname' already exists." >&2
ram54288 0:a7a43371b306 92 echo "*** Modifying a tag is not allowed in this repository." >&2
ram54288 0:a7a43371b306 93 exit 1
ram54288 0:a7a43371b306 94 fi
ram54288 0:a7a43371b306 95 ;;
ram54288 0:a7a43371b306 96 refs/heads/*,commit)
ram54288 0:a7a43371b306 97 # branch
ram54288 0:a7a43371b306 98 if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
ram54288 0:a7a43371b306 99 echo "*** Creating a branch is not allowed in this repository" >&2
ram54288 0:a7a43371b306 100 exit 1
ram54288 0:a7a43371b306 101 fi
ram54288 0:a7a43371b306 102 ;;
ram54288 0:a7a43371b306 103 refs/heads/*,delete)
ram54288 0:a7a43371b306 104 # delete branch
ram54288 0:a7a43371b306 105 if [ "$allowdeletebranch" != "true" ]; then
ram54288 0:a7a43371b306 106 echo "*** Deleting a branch is not allowed in this repository" >&2
ram54288 0:a7a43371b306 107 exit 1
ram54288 0:a7a43371b306 108 fi
ram54288 0:a7a43371b306 109 ;;
ram54288 0:a7a43371b306 110 refs/remotes/*,commit)
ram54288 0:a7a43371b306 111 # tracking branch
ram54288 0:a7a43371b306 112 ;;
ram54288 0:a7a43371b306 113 refs/remotes/*,delete)
ram54288 0:a7a43371b306 114 # delete tracking branch
ram54288 0:a7a43371b306 115 if [ "$allowdeletebranch" != "true" ]; then
ram54288 0:a7a43371b306 116 echo "*** Deleting a tracking branch is not allowed in this repository" >&2
ram54288 0:a7a43371b306 117 exit 1
ram54288 0:a7a43371b306 118 fi
ram54288 0:a7a43371b306 119 ;;
ram54288 0:a7a43371b306 120 *)
ram54288 0:a7a43371b306 121 # Anything else (is there anything else?)
ram54288 0:a7a43371b306 122 echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
ram54288 0:a7a43371b306 123 exit 1
ram54288 0:a7a43371b306 124 ;;
ram54288 0:a7a43371b306 125 esac
ram54288 0:a7a43371b306 126
ram54288 0:a7a43371b306 127 # --- Finished
ram54288 0:a7a43371b306 128 exit 0