Re: git-describe --tags warning: 'X' is really 'Y' here

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

 



On Wed, Feb 5, 2020 at 11:13 AM Roland Hieber <rhi@xxxxxxxxxxxxxx> wrote:
>
> Hi,

Hi, Roland

> I'm working with the GCC Git repo [0] (which was apparently recently
> converted from SVN [1]), and I'm trying to find out the most recent tag.
> So on the master branch I do:
>
>     gcc (master) $ git describe --tags --abbrev=0
>     warning: tag 'gcc_9_2_0_release' is really 'releases/gcc-9.2.0' here
>     gcc_9_2_0_release
>
> It took me a while to find out what the warning means, because
> 'gcc_9_2_0_release' is not in $(git tag -l), and it cannot be used as a
> ref either:
>
>     gcc (master) $ git show gcc_9_2_0_release
>     fatal: ambiguous argument 'gcc_9_2_0_release': unknown revision or path not in the working tree.
>     Use '--' to separate paths from revisions, like this:
>     'git <command> [<revision>...] -- [<file>...]'
>
> That name is in the tag itself:
>
>     gcc (master) $ git show releases/gcc-9.2.0 | head -n3
>     tag gcc_9_2_0_release
>     Tagger: Jakub Jelinek <jakub@xxxxxxxxxxx>
>     Date:   2019-08-12 09:38:59

It seems that the commit which added the output message you got is
212945d ("Teach git-describe to verify annotated tag names before
output", 2008-02-28) [1]. As the commit message states, the warning is
emitted when a tag is locally stored under a different name from the
one it was originally created (being the former the one you will want
to use at `git show`).

A simple way to replicate what you experienced in a fresh repo is with:

$ git tag -am "testing tag body" testing-tag
$ mv .git/refs/tags/testing-tag .git/refs/tags/testing-tag-with-new-name
$ git describe --tags --abbrev=0

Which outputs:

warning: tag 'testing-tag' is really 'testing-tag-with-new-name' here
testing-tag

And in fact, if we take a look at the tag with hash `dbb1e12` in GCC's
repo (using `git cat-file -p dbb1e12`) we see that the tag was
originally created with the name "gcc_9_2_0_release" (that is the name
stored in the tag object body). But the reference was later renamed,
since, in the `.git/packed-refs` file, we find the said hash
associated with "refs/tags/releases/gcc-9.2.0". I think that is what
`git tag` is warning you about.

> So my question is: is it the intended behaviour of 'git-describe --tags'
> that it outputs tag names that cannot be used as a ref? If so, what is a
> good other way to find out the most recent tag?
>

Hm, other than using the name provided in the warning, I don't know
about a more 'direct' way. But I'm not very used to `git describe`s
code, probably others can suggest a better option :)

---
Matheus

[1]: https://github.com/git/git/commit/212945d4a85dfa172ea55ec73b1d830ef2d8582f



[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]

  Powered by Linux