aboutsummaryrefslogtreecommitdiff
path: root/git-tag.sh
diff options
context:
space:
mode:
authorMatthijs Melchior <mmelchior@xs4all.nl>2007-06-03 02:05:39 +0200
committerJunio C Hamano <junkio@cox.net>2007-06-02 20:04:14 -0700
commit980ea5c5bb1dfbbf93b919942c703b9158c35968 (patch)
tree08f020d817f13121e34299d2216359ef2eeec542 /git-tag.sh
parentc94bf41c9a78dc1c084f2a2895f95b6b6d8f79b1 (diff)
downloadgit-980ea5c5bb1dfbbf93b919942c703b9158c35968.tar.gz
git-980ea5c5bb1dfbbf93b919942c703b9158c35968.tar.xz
Teach git-tag about showing tag annotations.
The <pattern> for -l is now a shell pattern, not a list of grep parameters. Option -l may be repeated with another <pattern>. The new -n [<num>] option specifies how many lines from the annotation are to be printed. Not specifieing -n or -n 0 will just produce the tag names Just -n or -n 1 will show the first line of the annotation on the tag line. Other valuse for -n will show that number of lines from the annotation. The exit code used to indicate if any tag was found. This is changed due to a different implementation. A good way to test a tag for existence is to use: git show-ref --quiet --verify refs/tags/$TAGNAME Signed-off-by: Matthijs Melchior <mmelchior@xs4all.nl> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-tag.sh')
-rwxr-xr-xgit-tag.sh44
1 files changed, 37 insertions, 7 deletions
diff --git a/git-tag.sh b/git-tag.sh
index 6f0b7a721..37cee978d 100755
--- a/git-tag.sh
+++ b/git-tag.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (c) 2005 Linus Torvalds
-USAGE='-l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
+USAGE='[-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
SUBDIRECTORY_OK='Yes'
. git-sh-setup
@@ -13,6 +13,7 @@ message=
username=
list=
verify=
+LINES=0
while case "$#" in 0) break ;; esac
do
case "$1" in
@@ -26,14 +27,41 @@ do
-f)
force=1
;;
- -l)
- case "$#" in
- 1)
- set x . ;;
+ -n)
+ case $2 in
+ -*) LINES=1 # no argument
+ ;;
+ *) shift
+ LINES=$(expr "$1" : '\([0-9]*\)')
+ [ -z "$LINES" ] && LINES=1 # 1 line is default when -n is used
+ ;;
esac
+ ;;
+ -l)
+ list=1
shift
- git rev-parse --symbolic --tags | sort | grep "$@"
- exit $?
+ PATTERN="$1" # select tags by shell pattern, not re
+ git rev-parse --symbolic --tags | sort |
+ while read TAG
+ do
+ case "$TAG" in
+ *$PATTERN*) ;;
+ *) continue ;;
+ esac
+ [ "$LINES" -le 0 ] && { echo "$TAG"; continue ;}
+ OBJTYPE=$(git cat-file -t "$TAG")
+ case $OBJTYPE in
+ tag) ANNOTATION=$(git cat-file tag "$TAG" |
+ sed -e '1,/^$/d' \
+ -e '/^-----BEGIN PGP SIGNATURE-----$/Q' )
+ printf "%-15s %s\n" "$TAG" "$ANNOTATION" |
+ sed -e '2,$s/^/ /' \
+ -e "${LINES}q"
+ ;;
+ *) echo "$TAG"
+ ;;
+ esac
+ done
;;
-m)
annotate=1
@@ -97,6 +125,8 @@ do
shift
done
+[ -n "$list" ] && exit 0
+
name="$1"
[ "$name" ] || usage
prev=0000000000000000000000000000000000000000