aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-06-06 02:29:41 -0700
committerJunio C Hamano <gitster@pobox.com>2007-06-06 02:29:41 -0700
commit6abd0fb396a0c575dafd4e1021d37d178740396c (patch)
tree8360910ff86d880cd62ac027cf36fa0bd81ca3e4
parent11f68d908229d1e954009805cd139a89872b9208 (diff)
parent980ea5c5bb1dfbbf93b919942c703b9158c35968 (diff)
downloadgit-6abd0fb396a0c575dafd4e1021d37d178740396c.tar.gz
git-6abd0fb396a0c575dafd4e1021d37d178740396c.tar.xz
Merge branch 'mm/tag'
* mm/tag: Teach git-tag about showing tag annotations.
-rw-r--r--Documentation/git-tag.txt13
-rwxr-xr-xgit-tag.sh44
2 files changed, 46 insertions, 11 deletions
diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
index 4e3e02756..aee2c1bdc 100644
--- a/Documentation/git-tag.txt
+++ b/Documentation/git-tag.txt
@@ -11,7 +11,7 @@ SYNOPSIS
[verse]
'git-tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <name> [<head>]
'git-tag' -d <name>...
-'git-tag' -l [<pattern>]
+'git-tag' [-n [<num>]] -l [<pattern>]
'git-tag' -v <name>
DESCRIPTION
@@ -38,8 +38,8 @@ GnuPG key for signing.
`-v <tag>` verifies the gpg signature of the tag.
-`-l <pattern>` lists tags that match the given pattern (or all
-if no pattern is given).
+`-l <pattern>` lists tags with names that match the given pattern
+(or all if no pattern is given).
OPTIONS
-------
@@ -61,8 +61,13 @@ OPTIONS
-v::
Verify the gpg signature of given the tag
+-n <num>::
+ <num> specifies how many lines from the annotation, if any,
+ are printed when using -l.
+ The default is not to print any annotation lines.
+
-l <pattern>::
- List tags that match the given pattern (or all if no pattern is given).
+ List tags with names that match the given pattern (or all if no pattern is given).
-m <msg>::
Use the given tag message (instead of prompting)
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