[PATCH] Handle tags outside of refs/tags gracefully.

Gianni Ceccarelli dakkar at thenautilus.net
Tue Jan 5 13:40:10 UTC 2021


On 2021-01-05 John Keeping <john at keeping.me.uk> wrote:
> I think something like option 2 is the right answer here, since that
> brings us closer to Git's behaviour.

``git tag`` never looks anywhere but under ``refs/tags/``. Not even
``git tag --contains`` will show annotated tags that are only
referenced outside that path.

OTOH (on my example repo)::

  $ git show HEAD
  commit 4081ad6720f3f60f5f11a77f1d932517496e33ba (HEAD -> master, refs/weird/thing, tag: refs/weird/annotated, tag: foo, origin/master, origin/HEAD)
  Author: dakkar <dakkar at thenautilus.net>
  Date:   2020-12-29 20:10:18 +0000

      first

  $ git tag -v refs/weird/annotated
  error: tag 'refs/weird/annotated' not found.

So maybe CGit is already behaving very closely to git.
  
> Does the patch below help?
>
> [snip]
>  
> +static const char *tag_patterns[] = {
> +	"%s",
> +	"refs/%s",
> +	"refs/tags/%s",
> +	NULL
> +};

I feel like those strings should be in the reverse order: we've been
asked to show a tag, let's try to resolve the ref as an actual tag
before guessing.

-- 
	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88



More information about the CGit mailing list