{"thread":{"id":"8404","subject":"[PATCH] Teach git-tag about showing tag annotations.","startedAt":"2007-06-03T00:05:39Z","lastAt":"2007-06-03T00:05:39Z","messageCount":1,"participants":["Matthijs Melchior"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43837","messageId":"11808291391915-git-send-email-mmelchior@xs4all.nl","threadId":"8404","inReplyTo":null,"subject":"[PATCH] Teach git-tag about showing tag annotations.","fromName":"Matthijs Melchior","fromEmail":"mmelchior@xs4all.nl","sentAt":"2007-06-03T00:05:39Z","receivedAt":"2007-06-03T00:05:39Z","isPatch":true,"sender":{"key":"mmelchior@xs4all.nl","avatar":null},"body":"The <pattern> for -l is now a shell pattern, not a list of grep parameters.\nOption -l may be repeated with another <pattern>.\n\nThe new -n [<num>] option specifies how many lines from\nthe annotation are to be printed.\nNot specifieing -n or -n 0 will just produce the tag names\nJust -n or -n 1 will show the first line of the annotation on\nthe tag line.\nOther valuse for -n will show that number of lines from the annotation.\n\nThe exit code used to indicate if any tag was found.\nThis is changed due to a different implementation.\n\nA good way to test a tag for existence is to use:\ngit show-ref --quiet --verify refs/tags/$TAGNAME\n\nSigned-off-by: Matthijs Melchior <mmelchior@xs4all.nl>\n---\n Documentation/git-tag.txt |   13 +++++++++----\n git-tag.sh                |   44 +++++++++++++++++++++++++++++++++++++-------\n 2 files changed, 46 insertions(+), 11 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 4e3e027..aee2c1b 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -11,7 +11,7 @@ SYNOPSIS\n [verse]\n 'git-tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]  <name> [<head>]\n 'git-tag' -d <name>...\n-'git-tag' -l [<pattern>]\n+'git-tag' [-n [<num>]] -l [<pattern>]\n 'git-tag' -v <name>\n \n DESCRIPTION\n@@ -38,8 +38,8 @@ GnuPG key for signing.\n \n `-v <tag>` verifies the gpg signature of the tag.\n \n-`-l <pattern>` lists tags that match the given pattern (or all\n-if no pattern is given).\n+`-l <pattern>` lists tags with names that match the given pattern\n+(or all if no pattern is given).\n \n OPTIONS\n -------\n@@ -61,8 +61,13 @@ OPTIONS\n -v::\n \tVerify the gpg signature of given the tag\n \n+-n <num>::\n+\t<num> specifies how many lines from the annotation, if any,\n+\tare printed when using -l.\n+\tThe default is not to print any annotation lines.\n+\n -l <pattern>::\n-\tList tags that match the given pattern (or all if no pattern is given).\n+\tList tags with names that match the given pattern (or all if no pattern is given).\n \n -m <msg>::\n \tUse the given tag message (instead of prompting)\ndiff --git a/git-tag.sh b/git-tag.sh\nindex 6f0b7a7..1563696 100755\n--- a/git-tag.sh\n+++ b/git-tag.sh\n@@ -1,7 +1,7 @@\n #!/bin/sh\n # Copyright (c) 2005 Linus Torvalds\n \n-USAGE='-l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'\n+USAGE='[-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n@@ -13,6 +13,7 @@ message=\n username=\n list=\n verify=\n+LINES=0\n while case \"$#\" in 0) break ;; esac\n do\n     case \"$1\" in\n@@ -26,14 +27,41 @@ do\n     -f)\n \tforce=1\n \t;;\n-    -l)\n-\tcase \"$#\" in\n-\t1)\n-\t\tset x . ;;\n+    -n)\n+        case $2 in\n+\t-*)\tLINES=1 \t# no argument\n+\t\t;;\n+\t*)\tshift\n+\t\tLINES=$(expr \"$1\" : '\\([0-9]*\\)')\n+\t\t[ -z \"$LINES\" ] && LINES=1 # 1 line is default when -n is used\n+\t\t;;\n \tesac\n+\t;;\n+    -l)\n+\tlist=1\n \tshift\n-\tgit rev-parse --symbolic --tags | sort | grep \"$@\"\n-\texit $?\n+\tPATTERN=\"$1\"\t# select tags by shell pattern, not re\n+\tgit rev-parse --symbolic --tags | sort |\n+\t    while read TAG\n+\t    do\n+\t        case \"$TAG\" in\n+\t\t*$PATTERN*) ;;\n+\t\t*)\t    continue ;;\n+\t\tesac\n+\t\t[ \"$LINES\" -le 0 ] && { echo \"$TAG\"; continue ;}\n+\t\tOBJTYPE=$(git cat-file -t \"$TAG\")\n+\t\tcase $OBJTYPE in\n+\t\ttag)\tANNOTATION=$(git cat-file tag \"$TAG\" |\n+\t\t\t    \t       sed -e '1,/^$/d' \\\n+\t\t\t\t\t   -e '/^-----BEGIN PGP SIGNATURE-----$/Q' )\n+\t\t\tprintf \"%-15s %s\\n\" \"$TAG\" \"$ANNOTATION\" |\n+\t\t\t  sed -e '2,$s/^/    /' \\\n+\t\t\t      -e \"${LINES}q\"\n+\t\t\t;;\n+\t\t*)      echo \"$TAG\"\n+\t\t\t;;\n+\t\tesac\n+\t    done\n \t;;\n     -m)\n     \tannotate=1\n@@ -97,6 +125,8 @@ do\n     shift\n done\n \n+[ -n \"$list\" ] && exit 0\n+\n name=\"$1\"\n [ \"$name\" ] || usage\n prev=0000000000000000000000000000000000000000\n-- \n1.5.2\n"}]}