[PATCH] Have sample update hook not refuse deleting a branch through push.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 templates/hooks--update |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/templates/hooks--update b/templates/hooks--update
index 0dcb1ad..9d3795c 100644
--- a/templates/hooks--update
+++ b/templates/hooks--update
@@ -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)
-- 
1.5.1.1

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]