git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthijs Melchior <mmelchior@xs4all.nl>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org, Matthijs Melchior <mmelchior@xs4all.nl>
Subject: [PATCH] Add option -L to git-tag.
Date: Sat,  2 Jun 2007 15:10:48 +0200	[thread overview]
Message-ID: <1180789848873-git-send-email-mmelchior@xs4all.nl> (raw)

  This will list the selected tags and include annotations, if any.

Signed-off-by: Matthijs Melchior <mmelchior@xs4all.nl>
---

Version 2 of the git-tag -L patch.
  It implements better style,
   a new --pretty=n option and
   an interresting exit code.

  -Matthijs

 Documentation/git-tag.txt |    5 ++++-
 git-tag.sh                |   24 +++++++++++++++++-------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
index 4e3e027..441f361 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' [-l | -L] [<pattern>]
 'git-tag' -v <name>
 
 DESCRIPTION
@@ -41,6 +41,9 @@ GnuPG key for signing.
 `-l <pattern>` lists tags that match the given pattern (or all
 if no pattern is given).
 
+`-L <pattern>` lists tags, including their annotations, that match
+the given pattern (or all if no pattern is given).
+
 OPTIONS
 -------
 -a::
diff --git a/git-tag.sh b/git-tag.sh
index 6f0b7a7..45c4253 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='[-l | -L] [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
 SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
@@ -26,13 +26,23 @@ do
     -f)
 	force=1
 	;;
-    -l)
-	case "$#" in
-	1)
-		set x . ;;
-	esac
+    -l|-L)
+	TAGSONLY=true
+	[ "$1" = -L ] && TAGSONLY=false
+	[ "$#" = 1 ] && set x .
 	shift
-	git rev-parse --symbolic --tags | sort | grep "$@"
+	git rev-parse --symbolic --tags | grep "$@" |
+	    while read TAG
+	    do
+		echo "$TAG"
+		$TAGSONLY && continue
+		OBJTYPE=$(git cat-file -t "$TAG")
+		case $OBJTYPE in
+		    tag)    git cat-file $OBJTYPE "$TAG" |
+				sed '1,/^$/d;/^-----BEGIN PGP SIGNATURE-----$/Q;s/^/    /'
+			    ;;
+		esac
+	    done
 	exit $?
 	;;
     -m)
-- 
1.5.2


>From f0123e2f1c4bd8a15e8d190dc1e0c2745db60278 Mon Sep 17 00:00:00 2001
From: Matthijs Melchior <mmelchior@xs4all.nl>
Date: Sat, 2 Jun 2007 15:04:46 +0200
Subject: [PATCH] git-tag -L, version 2
	style. --pretty=n and exit code
---
 git-tag.sh |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/git-tag.sh b/git-tag.sh
index 45c4253..dafa083 100755
--- a/git-tag.sh
+++ b/git-tag.sh
@@ -13,6 +13,7 @@ message=
 username=
 list=
 verify=
+LINES=3
 while case "$#" in 0) break ;; esac
 do
     case "$1" in
@@ -26,24 +27,33 @@ do
     -f)
 	force=1
 	;;
+    --pretty=*)
+	LINES=$(expr "$1" : '--pretty=\(.*\)')
+	;;
     -l|-L)
 	TAGSONLY=true
 	[ "$1" = -L ] && TAGSONLY=false
 	[ "$#" = 1 ] && set x .
 	shift
-	git rev-parse --symbolic --tags | grep "$@" |
+	[ "$LINES" -le 0 ] && LINES=999999
+	TAGLIST=$(git rev-parse --symbolic --tags | grep "$@")
+	RC=$?			# from grep
+	printf "%s" "$TAGLIST" |
 	    while read TAG
 	    do
 		echo "$TAG"
 		$TAGSONLY && continue
 		OBJTYPE=$(git cat-file -t "$TAG")
 		case $OBJTYPE in
-		    tag)    git cat-file $OBJTYPE "$TAG" |
-				sed '1,/^$/d;/^-----BEGIN PGP SIGNATURE-----$/Q;s/^/    /'
-			    ;;
+		tag)	git cat-file tag "$TAG" |
+			  sed -e '1,/^$/d' \
+			      -e '/^-----BEGIN PGP SIGNATURE-----$/Q' \
+			      -e 's/^/    /' |
+			  sed -e "${LINES}q"
+			;;
 		esac
 	    done
-	exit $?
+	exit $RC
 	;;
     -m)
     	annotate=1
-- 
1.5.2

             reply	other threads:[~2007-06-02 13:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-02 13:10 Matthijs Melchior [this message]
2007-06-02 14:49 ` [PATCH] Add option -L to git-tag Frank Lichtenheld
  -- strict thread matches above, loose matches on Subject: below --
2007-06-02  8:37 Matthijs Melchior
2007-06-02 10:10 ` Junio C Hamano
2007-06-02 13:09   ` Matthijs Melchior
2007-06-02 18:22     ` Junio C Hamano
2007-06-03  0:04       ` Matthijs Melchior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1180789848873-git-send-email-mmelchior@xs4all.nl \
    --to=mmelchior@xs4all.nl \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).