{"thread":{"id":"19233","subject":"[PATCH] fix sample update hook, disable overwriting of existing tags","startedAt":"2009-05-07T16:40:23Z","lastAt":"2009-05-08T15:22:30Z","messageCount":3,"participants":["Heiko Voigt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"113232","messageId":"20090507164023.GB5807@macbook.lan","threadId":"19233","inReplyTo":null,"subject":"[PATCH] fix sample update hook, disable overwriting of existing tags","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2009-05-07T16:40:23Z","receivedAt":"2009-05-07T16:40:23Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Because no special rule for this existed it was allowed by default\n\nSigned-off-by: Heiko Voigt <heiko.voigt@mahr.de>\n---\n templates/hooks--update.sample |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/templates/hooks--update.sample b/templates/hooks--update.sample\nindex f8bf490..68da609 100755\n--- a/templates/hooks--update.sample\n+++ b/templates/hooks--update.sample\n@@ -82,6 +82,12 @@ case \"$refname\",\"$newrev_type\" in\n \t\t;;\n \trefs/tags/*,tag)\n \t\t# annotated tag\n+\t\tif [ \"$allowdeletetag\" != \"true\" ] && git rev-parse $refname > /dev/null 2>&1\n+\t\tthen\n+\t\t\techo \"*** Tag '$refname' already exists.\" >&2\n+\t\t\techo \"*** Overwriting a tag is not allowed in this repository.\" >&2\n+\t\t\texit 1\n+\t\tfi\n \t\t;;\n \trefs/heads/*,commit)\n \t\t# branch\n-- \n1.6.2.1.423.g442d\n"},{"id":"113289","messageId":"7vzldobgrm.fsf@alter.siamese.dyndns.org","threadId":"19233","inReplyTo":"20090507164023.GB5807@macbook.lan","subject":"Re: [PATCH] fix sample update hook, disable overwriting of existing tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-08T00:05:49Z","receivedAt":"2009-05-08T00:05:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Heiko Voigt <hvoigt@hvoigt.net> writes:\n\n> Because no special rule for this existed it was allowed by default\n\nI do not disagree that it is a good thing to be able to reject\noverwriting, but I do not think it is a _fix_.  allowdeletetag is about\n_deletion_ and it already is covered by the code, isn't it?\n\nI think it would make more sense to introduce $allowmodifytag and reject\nsuch pushes in the codepath you touched.\n"},{"id":"113352","messageId":"20090508152230.GA7802@macbook.lan","threadId":"19233","inReplyTo":"7vzldobgrm.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] Extend sample update hook, disable modifying of existing tags","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2009-05-08T15:22:30Z","receivedAt":"2009-05-08T15:22:30Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Because no special rule for this existed it was allowed by default\n\nSigned-off-by: Heiko Voigt <heiko.voigt@mahr.de>\n---\nOn Thu, May 07, 2009 at 05:05:49PM -0700, Junio C Hamano wrote:\n> Heiko Voigt <hvoigt@hvoigt.net> writes:\n> \n> > Because no special rule for this existed it was allowed by default\n> \n> I do not disagree that it is a good thing to be able to reject\n> overwriting, but I do not think it is a _fix_.  allowdeletetag is about\n> _deletion_ and it already is covered by the code, isn't it?\n> I think it would make more sense to introduce $allowmodifytag and reject\n> such pushes in the codepath you touched.\n\nYou are (as usual) right. I was actually thinking about adding another\nvariable but then thought it might become to complex, but if you are\nasking for it.  Here it is ;)\n\ncheers Heiko\n\n templates/hooks--update.sample |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/templates/hooks--update.sample b/templates/hooks--update.sample\nindex f8bf490..fd63b2d 100755\n--- a/templates/hooks--update.sample\n+++ b/templates/hooks--update.sample\n@@ -13,6 +13,9 @@\n # hooks.allowdeletetag\n #   This boolean sets whether deleting tags will be allowed in the\n #   repository.  By default they won't be.\n+# hooks.allowmodifytag\n+#   This boolean sets whether a tag may be modified after creation. By default\n+#   it won't be.\n # hooks.allowdeletebranch\n #   This boolean sets whether deleting branches will be allowed in the\n #   repository.  By default they won't be.\n@@ -44,6 +47,7 @@ allowunannotated=$(git config --bool hooks.allowunannotated)\n allowdeletebranch=$(git config --bool hooks.allowdeletebranch)\n denycreatebranch=$(git config --bool hooks.denycreatebranch)\n allowdeletetag=$(git config --bool hooks.allowdeletetag)\n+allowmodifytag=$(git config --bool hooks.allowmodifytag)\n \n # check for no description\n projectdesc=$(sed -e '1q' \"$GIT_DIR/description\")\n@@ -82,6 +86,12 @@ case \"$refname\",\"$newrev_type\" in\n \t\t;;\n \trefs/tags/*,tag)\n \t\t# annotated tag\n+\t\tif [ \"$allowmodifytag\" != \"true\" ] && git rev-parse $refname > /dev/null 2>&1\n+\t\tthen\n+\t\t\techo \"*** Tag '$refname' already exists.\" >&2\n+\t\t\techo \"*** Modifying a tag is not allowed in this repository.\" >&2\n+\t\t\texit 1\n+\t\tfi\n \t\t;;\n \trefs/heads/*,commit)\n \t\t# branch\n-- \n1.6.2.1.423.g442d\n"}]}