summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c94bf41)
raw | patch | inline | side by side (parent: c94bf41)
author | Matthijs Melchior <mmelchior@xs4all.nl> | |
Sun, 3 Jun 2007 00:05:39 +0000 (02:05 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 3 Jun 2007 03:04:14 +0000 (20:04 -0700) |
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>
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>
Documentation/git-tag.txt | patch | blob | history | |
git-tag.sh | patch | blob | history |
index 4e3e02756c8863dbc6fe1d745e1a8c9a97c18919..aee2c1bdc785259c3f587323b557f5c575f3c797 100644 (file)
[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
`-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
-------
-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 6f0b7a72192bbeb7ca4693f40f80e2bd20d5eb03..37cee978d2b684c1f0965700bc687802ecc63851 100755 (executable)
--- a/git-tag.sh
+++ b/git-tag.sh
#!/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
username=
list=
verify=
+LINES=0
while case "$#" in 0) break ;; esac
do
case "$1" in
-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
shift
done
+[ -n "$list" ] && exit 0
+
name="$1"
[ "$name" ] || usage
prev=0000000000000000000000000000000000000000