{"thread":{"id":"1339","subject":"[PATCH] git-tag-script updates.","startedAt":"2005-07-25T23:02:58Z","lastAt":"2005-07-25T23:02:58Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6446","messageId":"7vek9mh4kd.fsf@assigned-by-dhcp.cox.net","threadId":"1339","inReplyTo":null,"subject":"[PATCH] git-tag-script updates.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-25T23:02:58Z","receivedAt":"2005-07-25T23:02:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This adds -a (annotate only but not sign) option \"A Large Angry\nSCM\" <gitzilla@gmail.com> sent to the list, after fixing up the\nwhitespace corruption in the patch, with some of my own fixes.\n\nNamely, changes are:\n\n * A new flag '-a' can be used to create an unsigned tag\n   object;\n\n * The '-f' flag logic did not do the right thing;\n\n * When creating a signed tag, we did not check for GPG failure\n   as we should;\n\n * Try to use the key for the tagger identity when signing the\n   tag.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n git-tag-script |   32 ++++++++++++++++++++++++++------\n 1 files changed, 26 insertions(+), 6 deletions(-)\n\n0fad0fdd4beadb2ff06af8d5a16d509cd8796ee4\ndiff --git a/git-tag-script b/git-tag-script\n--- a/git-tag-script\n+++ b/git-tag-script\n@@ -3,17 +3,30 @@\n \n . git-sh-setup-script || die \"Not a git archive\"\n \n+usage () {\n+    echo >&2 \"Usage: git-tag-script [-a | -s] [-f] tagname\"\n+    exit 1\n+}\n+\n+annotate=\n signed=\n force=\n while case \"$#\" in 0) break ;; esac\n do\n     case \"$1\" in\n+    -a)\n+\tannotate=1\n+\t;;\n     -s)\n+\tannotate=1\n \tsigned=1\n \t;;\n     -f)\n \tforce=1\n \t;;\n+    -*)\n+        usage\n+\t;;\n     *)\n \tbreak\n \t;;\n@@ -22,16 +35,19 @@ do\n done\n \n name=\"$1\"\n-[ \"$name\" ] || die \"I need a tag-name\"\n-[ -e \"$GIT_DIR/refs/tags/$name\" ] &&\n-\t[ \"$force\" ] || die \"tag '$name' already exists\"\n+[ \"$name\" ] || usage\n+if [ -e \"$GIT_DIR/refs/tags/$name\" -a -z \"$force\" ]; then\n+    die \"tag '$name' already exists\"\n+fi\n shift\n \n object=$(git-rev-parse --verify --revs-only --default HEAD \"$@\") || exit 1\n type=$(git-cat-file -t $object) || exit 1\n tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1\n \n-if [ \"$signed\" ]; then\n+trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0\n+\n+if [ \"$annotate\" ]; then\n     ( echo \"#\"\n       echo \"# Write a tag message\"\n       echo \"#\" ) > .editmsg\n@@ -43,9 +59,13 @@ if [ \"$signed\" ]; then\n \n     ( echo -e \"object $object\\ntype $type\\ntag $name\\ntagger $tagger\\n\"; cat .tagmsg ) > .tmp-tag\n     rm -f .tmp-tag.asc .tagmsg\n-    gpg -bsa .tmp-tag && cat .tmp-tag.asc >> .tmp-tag\n+    if [ \"$signed\" ]; then\n+\tme=$(expr \"$tagger\" : '\\(.*>\\)') &&\n+\tgpg -bsa -u \"$me\" .tmp-tag &&\n+\tcat .tmp-tag.asc >>.tmp-tag ||\n+\tdie \"failed to sign the tag with GPG.\"\n+    fi\n     object=$(git-mktag < .tmp-tag)\n-    rm -f .tmp-tag .tmp-tag.sig\n fi\n \n mkdir -p \"$GIT_DIR/refs/tags\"\n"}]}