Skip to content

Commit 9177649

Browse files
g-papeJunio C Hamano
authored andcommitted
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>
1 parent 5946d88 commit 9177649

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

templates/hooks--update

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ if [ -z "$projectdesc" -o "$projectdesc" = "Unnamed repository; edit this file t
4141
fi
4242

4343
# --- 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
4550

4651
case "$refname","$newrev_type" in
4752
refs/tags/*,commit)

0 commit comments

Comments
 (0)