threads / patch / 7675

patchvariable $projectdesc needs to be set before checking against unchanged default.

Subject: [PATCH] variable $projectdesc needs to be set before checking against unchanged default.

## tl;dr

2 messages between Apr 16, 2007 and Apr 16, 2007. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Gerrit Pape· Apr 16, 2007, 08:30 UTC · lore
Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 templates/hooks--update |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to templates/hooks--update +1 −0
diff --git a/templates/hooks--update b/templates/hooks--update
index 0ff0330..0dcb1ad 100644
--- a/templates/hooks--update
+++ b/templates/hooks--update
@@ -34,6 +34,7 @@ fi
 allowunannotated=$(git-repo-config --bool hooks.allowunannotated)
 
 # check for no description
+projectdesc=$(sed -e '1p' "$GIT_DIR/description")
 if [ -z "$projectdesc" -o "$projectdesc" = "Unnamed repository; edit this file to name it for gitweb" ]; then
 	echo "*** Project description file hasn't been set" >&2
 	exit 1
-- 
1.5.1.1
Gerrit Pape· Apr 16, 2007, 08:31 UTC · re: Gerrit Pape · lore

[PATCH] 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>
---
 templates/hooks--update |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Show changes to templates/hooks--update +6 −1
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

← back to recent threads