Extend sample update hook, disable modifying of existing tags
Because no special rule for this existed it was allowed by default Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Heiko Voigt committed
May 8, 2009 at 17:22 UTC
7742c65ba5d74f9cbb426f206a88ae04be3f46cd
1 file changed
+10
templates/hooks--update.sample
+10
@@ -13,6 +13,9 @@
13
# hooks.allowdeletetag
14
# This boolean sets whether deleting tags will be allowed in the
15
# repository. By default they won't be.
16
+# hooks.allowmodifytag
17
+# This boolean sets whether a tag may be modified after creation. By default
18
+# it won't be.
19
# hooks.allowdeletebranch
20
# This boolean sets whether deleting branches will be allowed in the
21
# repository. By default they won't be.
@@ -44,6 +47,7 @@ allowunannotated=$(git config --bool hooks.allowunannotated)
47
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
48
denycreatebranch=$(git config --bool hooks.denycreatebranch)
49
allowdeletetag=$(git config --bool hooks.allowdeletetag)
50
+allowmodifytag=$(git config --bool hooks.allowmodifytag)
51
52
# check for no description
53
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
@@ -82,6 +86,12 @@ case "$refname","$newrev_type" in
86
;;
87
refs/tags/*,tag)
88
# annotated tag
89
+ if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
90
+ then
91
+ echo "*** Tag '$refname' already exists." >&2
92
+ echo "*** Modifying a tag is not allowed in this repository." >&2
93
+ exit 1
94
+ fi
95
;;
96
refs/heads/*,commit)
97
# branch