Git already has an ordering like this built in as ‘git describe’.
https://git-scm.com/docs/git-describe
$ git describe 593a2a5d0639b4b4f91ff6e6ffb64e72020f8fd8
v2.34.1-83-g593a2a5d06
This commit is 83 commits after the v2.34.1 tag. Git accepts this identifier anywhere it would accept a commit hash, e.g.: $ git log v2.34.1-83-g593a2a5d06
$ git show v2.34.1-83-g593a2a5d06:branch.c
https://git.kernel.org/pub/scm/git/git.git/commit/?id=v2.34....