cogito: understand permissions written as "100755"
[cogito.git] / cg-tag-ls
blobf4c776cc1303345b30503032fbc9c2b230ce639a
1 #!/usr/bin/env bash
3 # List existing tags
4 # Copyright (c) Steve Hoelzer 2005
5 # Copyright (c) Petr Baudis 2006
7 # This command takes no arguments, and lists all tags in a given repository
8 # in alphabetical order, along with their corresponding SHA1 hash IDs.
10 # OUTPUT FORMAT
11 # -------------
12 # The first column contains flag letters. The 'S' flag means that the tag is
13 # GPG-signed, the '%' flag means that this is a "direct tag" (does not point
14 # to a tag object; this is now considered deprecated and you might have trouble
15 # distributing the tag to others). The '!' flag means that the tag is broken
16 # and points to a non-existing object.
18 # The second column shows the tag name, the third column its (abbreviated)
19 # object id and the fourth column the first line of tag description,
20 # if applicable.
22 # Testsuite: TODO
24 USAGE="cg-tag-ls"
25 _git_wc_unneeded=1
27 . "${COGITO_LIB}"cg-Xlib || exit 1
29 msg_no_tags="no tags present, please see cg-tag(1)"
31 [ -d "$_git/refs/tags" ] || die "$msg_no_tags"
33 [ "$(find "$_git/refs/tags" -follow -type f)" ] \
34 || die "$msg_no_tags"
36 maxlen="$(git-for-each-ref --format="%(refname)" refs/tags | column_width "refs/tags/")"
38 # %(content) and %(body) is broken for tags in git-1.4.4
40 git-for-each-ref --format="%(refname) %(objectname) %(subject)" refs/tags |
41 while read tag sha1 title; do
42 flag=" "
43 name="${tag#refs/tags/}"
45 type="$(git-cat-file -t "$sha1" 2>/dev/null)" || flag="!"
46 if [ "$type" = "tag" ]; then
47 git-cat-file tag "$sha1" | grep -q '^-----BEGIN PGP SIGNATURE-----' && flag="S"
48 elif [ "$type" ]; then
49 flag="%"
52 columns_print "$flag " - "$name" $maxlen " ${sha1:0:12}~" - " $title" -
53 done