Implement update hook for git submodules.
authorEvan Broder <broder@mit.edu>
Mon, 12 Oct 2009 06:16:25 +0000 (02:16 -0400)
committerEvan Broder <broder@mit.edu>
Mon, 12 Oct 2009 06:16:25 +0000 (02:16 -0400)
svn path=/trunk/scripts/git-hooks/; revision=2499

sub/update [new file with mode: 0755]

diff --git a/sub/update b/sub/update
new file mode 100755 (executable)
index 0000000..11adb92
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+ref="$1"
+oldrev="$2"
+newrev="$3"
+
+# --- Safety check
+
+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 "$ref" -o -z "$oldrev" -o -z "$newrev" ]; then
+        echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
+        exit 1
+fi
+
+# --- Disallow pushing tags
+
+case "$ref" in
+    refs/tags/*)
+        echo "*** Pushing tags to this repository is not allowed" >&2
+        exit 1
+        ;;
+esac