Re: feature "git tag -r" to show tags and commits they are pointing to

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eugene Sajine <euguess@xxxxxxxxx> 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}".

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]