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

Gianni Ceccarelli dakkar at thenautilus.net
Tue Dec 29 21:33:09 CET 2020


On Tue, 2020-12-29 at 12:37:43 +0100, Jason A. Donenfeld wrote:  
> This is for the tag UI, though. Aren't tags supposed to live in
> refs/tags/ by definition?

Yes. The "git tag" manpage says:

>> Add a tag reference in refs/tags/, unless -d/-l/-v is given to
>> delete, list or verify tags

On 2020-12-29 "Jason A. Donenfeld" <Jason at zx2c4.com> wrote:
> The fact that the git CLI handles it properly actually is a compelling
> reason to mimic its logic. How does it handle this scenario? I assume
> it looks up both possibilities and returns the first one that matches?
> In which order does it check?

Depends which sub-command we're talking about::

  $ mkdir /tmp/a
  $ cd /tmp/a
  $ git init
  $ touch foo && git add foo && git commit -m first
  $ mkdir .git/refs/weird && git rev-parse HEAD > .git/refs/weird/thing
  $ git log --decorate
  commit 4081ad6720f3f60f5f11a77f1d932517496e33ba (HEAD -> master, refs/weird/thing)
  Author: dakkar <dakkar at thenautilus.net>
  Date:   2020-12-29 20:10:18 +0000

    first

Now, ``git checkout weird/thing`` works, as does ``git log
weird/thing``, or anything that uses ``rev-parse`` internally.

``git tag`` will *not* show ``weird/thing`` because it's not a tag,
it's a non-tag ref::

  $ git tag -d weird/thing
  error: tag 'weird/thing' not found.

As far as CGit is concerned, these work:

* https://www.thenautilus.net/cgit/example/log/?h=weird/thing
* https://www.thenautilus.net/cgit/example/commit/?h=weird/thing
* https://www.thenautilus.net/cgit/example/tree/?h=weird/thing
* https://www.thenautilus.net/cgit/example/diff/?h=weird/thing

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