[go: up one dir, main page]

Skip to content

Add tooling to read direct value of a ref

It is impossible to read references without resolving them in any way when the type of a reference isn't known. This is because there are two different commands to read direct and symbolic refs:

  • git-rev-parse(1) can show any reference, but will resolve it to its pointee. This means that symbolic refs will not be marked as such by default.
  • git-symbolic-ref(1) can show symrefs, but you need to know that it's a symref in the first place.

This makes it quite cumbersome to generically read the exact value that such a reference points to and requires the callers to spawn two commands. This has been less of an issue with the reffiles backend as symrefs are always stored as loose refs and can thus be parsed comparatively easily if really required. But with the reftable backend it's harder to do this.

We should improve our tooling to support symrefs better. Most importantly, we should add a mode to e.g. git-show-ref(1) to not resolve references at all but instead print their value directly. Furthermore, it would be helpful if e.g. git-for-each-ref(1) had a mode to list matching refs in the same way.

Edited by Patrick Steinhardt