trebor
trebor

Reputation: 1003

Why does `git describe` show "warning: tag 'xxx' is externally known as 'refs/tags/xxx'"?

I am trying to use git describe to retrieve the latest tag name for the current branch, but I'm facing unexpected warnings in the output.

-> git describe
warning: tag 'v0.0.6' is externally known as 'refs/tags/v0.0.6'
refs/tags/v0.0.6-0-g5392899

-> git describe --tags
warning: tag 'v0.0.6' is externally known as 'refs/tags/v0.0.6'
refs/tags/v0.0.6-0-g5392899

-> git describe --tags --abbrev=0
warning: tag 'v0.0.6' is externally known as 'refs/tags/v0.0.6'
refs/tags/v0.0.6-0-g5392899c48d700b48e0dda16129dac6a60bb3b1e

As indicated, the tags locally do not have the refs/tags prefix:

-> git tag -l
v0.0.1
v0.0.2
v0.0.3
v0.0.4
v0.0.5
v0.0.6

However, I'm not sure why the warning is being received or what I can do about it.

The tags were not deleted and recreated, nor have they been renamed.

The tags are created from our build environment (Jenkins).

Is there something I can do to correct or work around the warning?

-> git show
commit 5392899c48d700b48e0dda16129dac6a60bb3b1e (HEAD -> master, tag: v0.0.6, origin/master, origin/HEAD)
...

-> git --version
git version 2.30.1 (Apple Git-130)

Edit:

Our Jenkins build which creates the tags uses jgit. The configuration for checking out the branch/code is as follows: jenkins git checkout

The tag creation is done using Git Publisher: jenkins git tag

Upvotes: 3

Views: 2434

Answers (1)

Marco Luzzara
Marco Luzzara

Reputation: 6036

I was able to reproduce the same error using git version 2.25.1. The only difference is that the error message returned is:

warning: tag 'refs/tags/1.0' is really '1.0' here

This warning comes from the append_name function and I guess the problem is that name_checked field is false. I tried to find some logic behind that field but I did not make it, besides I am not that good with C and I would have lost a day at least.

The warning you are seeing might be caused by something else, but it came out after I (manually) generated a discrepancy between .git/packed-refs, .git/refs/tags/1.0 and the tag object. Specifically, I created a tag named refs/tags/1.0, but I modified the .git/packed-refs like this:

975b54bb9b78e245f5abd1b10d6f090c4e0bbf58 refs/tags/1.0 # instead of refs/tags/refs/tags/1.0
^f84bc266f21fa641076a9bef0de4bf2ce1fa5090

However, unlike you, I am not seeing only the correct tag with git tag -l, but also the forged one.

Two advices for you: firstly I would check that those 3 files (.git/packed-refs, .git/refs/tags/your_tag and the tag object file in .git/objects) do not contain any contradictory reference. In either case, please edit your question with how the Git plugin for Jenkins clones the remote repository. If I am not mistaken, it tries hard to optimize performances by reducing at the minimum the references it checks out (and maybe there is just a bug in the plugin).

Upvotes: 2

Related Questions