Jim Meyering
2009-Jun-04 06:45 UTC
[Ovirt-devel] FYI, new git "update" script pushed, not yet installed
I noticed that the upstream version of our update script had evolved in git.git, so I merged their changes into ours. I haven't installed this server-side hook yet, because I don't know if your process requires moving tags. Let me know and I'll install the new version.>From 260c6c70a5b73c3ab7be705ed9da05b9c0b060fa Mon Sep 17 00:00:00 2001From: Jim Meyering <meyering at redhat.com> Date: Thu, 4 Jun 2009 08:41:01 +0200 Subject: [PATCH release] git-hooks/update: merge two new options from git.git's next branch: * update: add the two following options: hooks.allowmodifytag: default: false, i.e., no modifying an existing tag hooks.denycreatebranch: default: false, i.e., *allow* creating branches --- git-hook/update | 26 +++++++++++++++++++++++--- 1 files changed, 23 insertions(+), 3 deletions(-) diff --git a/git-hook/update b/git-hook/update index c82015e..ed76bd2 100755 --- a/git-hook/update +++ b/git-hook/update @@ -1,6 +1,6 @@ #!/bin/sh # -# An example hook script to blocks unannotated tags from entering. +# An example hook script to block unannotated tags from entering. # Called by "git receive-pack" with arguments: refname sha1-old sha1-new # # To enable this hook, rename this file to "update". @@ -13,9 +13,15 @@ # hooks.allowdeletetag # This boolean sets whether deleting tags will be allowed in the # repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. # hooks.allowdeletebranch # This boolean sets whether deleting branches will be allowed in the # repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. # # hooks.allowbadwhitespace # This boolean sets whether you may push a commit that adds bad whitespace. @@ -62,7 +68,9 @@ fi # --- Config allowunannotated=$(git config --bool hooks.allowunannotated) allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) # check for no description projectdesc=$(sed -e '1q' "$GIT_DIR/description") @@ -75,7 +83,8 @@ esac # --- Check types # if $newrev is 0000...0000, it's a commit to delete a ref. -if [ "$newrev" = "0000000000000000000000000000000000000000" ]; then +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then newrev_type=delete else newrev_type=$(git cat-file -t $newrev) @@ -101,9 +110,20 @@ case "$refname","$newrev_type" in ;; refs/tags/*,tag) # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi ;; refs/heads/*,commit) # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + check_diff=yes branch=${1##refs/heads/} deny_push_email=$(git config "hooks.denypush.branch.$branch") @@ -161,7 +181,7 @@ esac if [ $check_diff = yes ]; then allow_bad_whitespace=$(git config --bool hooks.allowbadwhitespace) if [ "$allow_bad_whitespace" != "true" ]; then - test "$oldrev" = 0000000000000000000000000000000000000000 \ + test "$oldrev" = $zero \ && exit 0 exec git diff --check $oldrev $newrev -- fi -- 1.6.3.1.333.g3ebba7
Alan Pevec
2009-Jun-04 09:47 UTC
[Ovirt-devel] Re: FYI, new git "update" script pushed, not yet installed
Jim Meyering wrote:> I noticed that the upstream version of our update script had > evolved in git.git, so I merged their changes into ours. > I haven't installed this server-side hook yet, because I don't > know if your process requires moving tags.Never! that's evil, if we ever screw up the release, we'll fix and tag as new minor release.> Let me know and I'll install the new version.please go ahead> hooks.allowmodifytag: default: false, i.e., no modifying an existing tagack> hooks.denycreatebranch: default: false, i.e., *allow* creating branchesack, it can be useful to push work-in-progress to public branches, e.g. David and Ian are using this in ovirt-server.git, dev/qmf branch