All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phil Hord <phil.hord@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Git tag output order is incorrect (IMHO)
Date: Wed, 11 Sep 2013 10:54:01 -0700	[thread overview]
Message-ID: <xmqqioy7tfba.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CABURp0o5tOswiv_avfAQOZwGREpX3v7MwcdVzt7dkubY2Y0O6g@mail.gmail.com> (Phil Hord's message of "Wed, 11 Sep 2013 09:42:27 -0400")

Phil Hord <phil.hord@gmail.com> writes:

> Someone at $work asked me this week how to find the current and
> previous tags on his branch so he could generate release notes.  I
> just need "last two tags on head in topo-order". I was surprised by
> how complicated this turned out to be. I ended up with this:
>
>   git log --decorate=full --pretty=format:'%d' HEAD |
>     sed -n -e 's-^.* refs/tags/\(.*\)[ )].*$-\1-p' |
>     head -2
>
> Surely there's a cleaner way, right?

That looks clean enough (I would have used "head -n 2" though) and
in line with the way how you can exercise the flexibility of the
system, at least to me ;-).

Joking aside, I agree that a "--merged X" primitive, i.e. "what refs
can be reachable from commit X?", in the listing mode of "git tag"
or "git for-each-ref" would have helped.  As the sorting and
formatting primitives are already there in for-each-ref, it would
have been

	git for-each-ref \
            --format='%(refname:short)' \
            --sort='-*committerdate' \
            --count=2 \
            --merged my-branch \
            refs/tags/

or something like that.

      reply	other threads:[~2013-09-11 17:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18 15:27 Git tag output order is incorrect (IMHO) Rahul Bansal
2013-07-18 15:51 ` Duy Nguyen
2013-07-18 15:56   ` Duy Nguyen
2013-07-18 15:58     ` Rahul Bansal
2013-07-18 15:57   ` Rahul Bansal
2013-07-18 16:14     ` Duy Nguyen
2013-07-18 17:42 ` Andreas Schwab
2013-07-19 19:40   ` Junio C Hamano
2013-07-20  0:22     ` Jeff King
2013-08-20 15:12       ` Antoine Pelisse
2013-09-08  8:03         ` Jeff King
2013-10-16 17:56           ` Jeff King
2013-10-16 18:06             ` Antoine Pelisse
2013-09-08 22:49 ` Felipe Contreras
2013-09-11 13:42   ` Phil Hord
2013-09-11 17:54     ` Junio C Hamano [this message]

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=xmqqioy7tfba.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=phil.hord@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.