git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eugene Sajine <euguess@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: feature "git tag -r" to show tags and commits they are pointing  to
Date: Thu, 22 Oct 2009 22:58:33 -0700	[thread overview]
Message-ID: <7v8wf2ejna.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <76c5b8580910221930s4b31b180t8298c262d9d9f421@mail.gmail.com> (Eugene Sajine's message of "Thu\, 22 Oct 2009 22\:30\:37 -0400")

Eugene Sajine <euguess@gmail.com> writes:

> I was looking for this info in order to create second tag for the same
> commit. For example if the first tag created by somebody or
> automatically (CI, release system), so i could add a verbose tag.
>
> But i just realized that i don't need commit id for that - just tag
> the tag, stupid...

You do not have to live with a tag that points at another tag that points
at a commit.

You can still tag the commit directly with your new tag, and you do not
need to have the exact commit object name to do so.  You just tell the
tool to follow the tag chain to get to the pointed-to object, like this:

    $ git tag -a -m "my message" newtag oldtag^0

This assumes [*1*] that the old tag points at (strictly speaking, "might
point at") a commit object, and uses "^0" (zeroth parent of) operator to
make sure that the object the newtag points at (the last argument to the
"git tag" command, i.e. "oldtag^0" in this example) is a commit object,
not an annotated tag "oldtag" itself.

That is what I meant by "just as usable as hexadecimal to the tools".

>> ... "v0.1" is
>> much more useful than 8794hke to humans, and these tag names are just as
>> usable as the hexadecimal commit object names to the tools.  You can say
>> "git show v0.1^0" and "git show 8794hke" and get the same thing.

[Footnote]

*1* A tag can point at any object, not necessarily a commit.  If oldtag
points at a tree object (or a blob object), oldtag^0 will fail, because
the operator "^0" is "zeroth parent of", and is applicable only to a
commit.  In general, you can write

    $ git tag -a -m "my message" newtag oldtag^{}

The "^{}" operator is a special case of "^{type}" operator; the former
means "dereference the tag repeatedly until it becomes something that is
not a tag", and the latter means "dereference the tag repeatedly until it
becomes something of that type".  I.e. "oldtag^0" is "oldtag^{commit}".

  reply	other threads:[~2009-10-23  5:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-22 21:24 feature "git tag -r" to show tags and commits they are pointing to Eugene Sajine
2009-10-22 21:35 ` Junio C Hamano
2009-10-23  2:30   ` Eugene Sajine
2009-10-23  5:58     ` Junio C Hamano [this message]
2009-10-23 14:48       ` Eugene Sajine

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=7v8wf2ejna.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=euguess@gmail.com \
    --cc=git@vger.kernel.org \
    /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).