Have sample update hook not refuse deleting a branch through push.
source ref might be 0000...0000 to delete a branch through git-push, 'git <remote> push :<branch>'. The update hook should not decline this. Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Gerrit Pape committed
Apr 16, 2007 at 08:31 UTC
91776491da19f1b72e1cd192c9ea42bb1aae4415
1 file changed
+6
-1
templates/hooks--update
+6
-1
@@ -41,7 +41,12 @@ if [ -z "$projectdesc" -o "$projectdesc" = "Unnamed repository; edit this file t
41
fi
42
43
# --- Check types
44
-newrev_type=$(git-cat-file -t $newrev)
44
+# if $newrev is 0000...0000, it's a commit to delete a branch
45
+if [ -z "${newrev##0*}" ]; then
46
+ newrev_type=commit
47
+else
48
+ newrev_type=$(git-cat-file -t $newrev)
49
+fi
50
51
case "$refname","$newrev_type" in
52
refs/tags/*,commit)