git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix sample update hook, disable overwriting of existing tags
@ 2009-05-07 16:40 Heiko Voigt
  2009-05-08  0:05 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Voigt @ 2009-05-07 16:40 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Because no special rule for this existed it was allowed by default

Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de>
---
 templates/hooks--update.sample |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample
index f8bf490..68da609 100755
--- a/templates/hooks--update.sample
+++ b/templates/hooks--update.sample
@@ -82,6 +82,12 @@ case "$refname","$newrev_type" in
 		;;
 	refs/tags/*,tag)
 		# annotated tag
+		if [ "$allowdeletetag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
+		then
+			echo "*** Tag '$refname' already exists." >&2
+			echo "*** Overwriting a tag is not allowed in this repository." >&2
+			exit 1
+		fi
 		;;
 	refs/heads/*,commit)
 		# branch
-- 
1.6.2.1.423.g442d

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix sample update hook, disable overwriting of existing tags
  2009-05-07 16:40 [PATCH] fix sample update hook, disable overwriting of existing tags Heiko Voigt
@ 2009-05-08  0:05 ` Junio C Hamano
  2009-05-08 15:22   ` [PATCH v2] Extend sample update hook, disable modifying " Heiko Voigt
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-05-08  0:05 UTC (permalink / raw)
  To: Heiko Voigt; +Cc: git

Heiko Voigt <hvoigt@hvoigt.net> writes:

> Because no special rule for this existed it was allowed by default

I do not disagree that it is a good thing to be able to reject
overwriting, but I do not think it is a _fix_.  allowdeletetag is about
_deletion_ and it already is covered by the code, isn't it?

I think it would make more sense to introduce $allowmodifytag and reject
such pushes in the codepath you touched.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] Extend sample update hook, disable modifying of existing tags
  2009-05-08  0:05 ` Junio C Hamano
@ 2009-05-08 15:22   ` Heiko Voigt
  0 siblings, 0 replies; 3+ messages in thread
From: Heiko Voigt @ 2009-05-08 15:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Because no special rule for this existed it was allowed by default

Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de>
---
On Thu, May 07, 2009 at 05:05:49PM -0700, Junio C Hamano wrote:
> Heiko Voigt <hvoigt@hvoigt.net> writes:
> 
> > Because no special rule for this existed it was allowed by default
> 
> I do not disagree that it is a good thing to be able to reject
> overwriting, but I do not think it is a _fix_.  allowdeletetag is about
> _deletion_ and it already is covered by the code, isn't it?
> I think it would make more sense to introduce $allowmodifytag and reject
> such pushes in the codepath you touched.

You are (as usual) right. I was actually thinking about adding another
variable but then thought it might become to complex, but if you are
asking for it.  Here it is ;)

cheers Heiko

 templates/hooks--update.sample |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample
index f8bf490..fd63b2d 100755
--- a/templates/hooks--update.sample
+++ b/templates/hooks--update.sample
@@ -13,6 +13,9 @@
 # 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.
@@ -44,6 +47,7 @@ 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")
@@ -82,6 +86,12 @@ 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
-- 
1.6.2.1.423.g442d

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-08 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-07 16:40 [PATCH] fix sample update hook, disable overwriting of existing tags Heiko Voigt
2009-05-08  0:05 ` Junio C Hamano
2009-05-08 15:22   ` [PATCH v2] Extend sample update hook, disable modifying " Heiko Voigt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).