]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Have sample update hook not refuse deleting a branch through push.
authorGerrit Pape <pape@smarden.org>
Mon, 16 Apr 2007 08:31:35 +0000 (08:31 +0000)
committerJunio C Hamano <junkio@cox.net>
Mon, 16 Apr 2007 08:35:39 +0000 (01:35 -0700)
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>
templates/hooks--update

index 0dcb1adb132d5d127bc6c693bac1528cb567e517..9d3795c6d055d3ca2b50ac0607607037cb2b8142 100644 (file)
@@ -41,7 +41,12 @@ if [ -z "$projectdesc" -o "$projectdesc" = "Unnamed repository; edit this file t
 fi
 
 # --- Check types
-newrev_type=$(git-cat-file -t $newrev)
+# if $newrev is 0000...0000, it's a commit to delete a branch
+if [ -z "${newrev##0*}" ]; then
+       newrev_type=commit
+else
+       newrev_type=$(git-cat-file -t $newrev)
+fi
 
 case "$refname","$newrev_type" in
        refs/tags/*,commit)