# [PATCH/RFC 0/6] sort tags by date (git tag -l -D)

3 messages from 2009-02-22 to 2009-02-23. Participants: Marc-André Lureau, Thomas Rast.
Thread: https://gitlist.dev/t/17951

## Marc-André Lureau, 2009-02-22 18:06

Subject: [PATCH/RFC 0/6] sort tags by date (git tag -l -D)
Message-ID: <e29894ca0902221006s1c1af9f9o8c13ff9e06670d95@mail.gmail.com>
URL: https://gitlist.dev/e/e29894ca0902221006s1c1af9f9o8c13ff9e06670d95%40mail.gmail.com

```
Hi,

I needed to sort my tags by date, and not only the annotated tags. I
was surprised that git tag didn't know how to do that. May be it could
be handled simply by some shell script. Please tell me :)

Take this patch series easy, it's only a RFC. I had some fun hacking
the code, that's the most important for me. I would be happy to take
comment.

Something I wish I could do is also have a better pretty_print_tag()
to have customized format (or may be it should be in git log instead?)

I tried different approach to deal with light tags, and none was
really good. In the end, I decided to use the "object" base type, and
have a private light_tag type. There might be different solutions to
that. I am happy to discuss them.

regards,

Marc-Andre Lureau (6):
  tag: read signature
  tag: parse the date
  tag: copy parsed buffer unconditionnaly
  object: add one bit to let creation of private types (OBJ_MAX + n)
  builtin-tag: add sort by date -D
  test: add simple sorted tag test

 builtin-tag.c  |  162 ++++++++++++++++++++++++++++++++++++++++++++-----------
 object.h       |    2 +-
 t/t7004-tag.sh |   53 ++++++++++++++++++
 tag.c          |   17 +++++-
 tag.h          |    5 ++-
 5 files changed, 201 insertions(+), 38 deletions(-)

```

## Thomas Rast, 2009-02-23 09:04

Subject: Re: [PATCH/RFC 0/6] sort tags by date (git tag -l -D)
Message-ID: <200902231004.25784.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200902231004.25784.trast%40student.ethz.ch
In-Reply-To: <e29894ca0902221006s1c1af9f9o8c13ff9e06670d95@mail.gmail.com>

```
Marc-André Lureau wrote:
> I needed to sort my tags by date, and not only the annotated tags.

As others have pointed out, there's no sane way to sort 

> I was surprised that git tag didn't know how to do that. May be it
> could be handled simply by some shell script. Please tell me :)

Modulo timezone differences

  git for-each-ref --format="%(taggerdate:raw)%(committerdate:raw) %(refname:short)" refs/tags | sort -n | cut -d\  -f3

For some neat reason only one of the dates is displayed, depending on
the type of object.

(Interestingly, the v0.99 tag in git.git doesn't have a date or
tagger...)

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```

## Thomas Rast, 2009-02-23 09:11

Subject: Re: [PATCH/RFC 0/6] sort tags by date (git tag -l -D)
Message-ID: <200902231011.54574.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200902231011.54574.trast%40student.ethz.ch
In-Reply-To: <200902231004.25784.trast@student.ethz.ch>

```
Thomas Rast wrote:
> Marc-André Lureau wrote:
> > I needed to sort my tags by date, and not only the annotated tags.
> 
> As others have pointed out, there's no sane way to sort
... lightweight tags of blobs or trees.

*sigh*

Also, do not take my shell command to mean that I don't like this
series.  It would be nice to have a porcelain feature for it.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```
