git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Gerrit Pape <pape@smarden.org>
Date
Apr 16, 2007, 08:31 UTC
Message-ID
<20070416083135.7528.qmail@3626b961fc9db3.315fe32.mid.smarden.org>
In-Reply-To
<20070416083042.7415.qmail@5f69bf745847ea.315fe32.mid.smarden.org>

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>
---
 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
Previous: Gerrit Pape
Message 2 of 2 in “variable $projectdesc needs to be set before checking against unchanged default.”
  1. variable $projectdesc needs to be set before checking against unchanged default.Gerrit Pape, Apr 16, 2007
  2. Have sample update hook not refuse deleting a branch through push.Gerrit Pape, Apr 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.