Why does git-describe prefix the commit ID with the letter 'g'?
git
Solution
Jesse Luehrs immediately pointed out on Twitter that this question is answered in the `git-describe` man page:
The "g" prefix stands for "git" and is used to allow describing the version of a software depending on the SCM the software is managed with.
Problem
Typical output of `git-describe` looks like ``` some-tag-32-gf31f980 ``` where `some-tag` is a tag name, `32` means that the described commit is 32 commits after the commit with that tag, and `gf31f980` means that the commit ID is uniquely abbreviated to `f31f980`. My question is about the `g` in `gf31f980`. Why is it there? My first thought was that it is inserted to disambiguate parsing of the output of `git-describe`. But I can't think of any case in which it actually helps to have it. For example, the `32` component might be omitted, and there is no way to know that the output above describes a commit 32 commits after the tag `some-tag`, rather than the commit at the tag `some-tag-32`. But the `g` doesn't help with this. A regex match to extract just the commit ID can search for `/-g([0-9a-f]+)$/`. There is no easy way to simplify this; you can't do `/-g(.*)$/` for example because that might erroneously match a `g` in the tag name. Without the `g` you could still do `/-([0-9a-f]+)$/`, so the `g` isn't helping you there. Non-regex parsing processes will behave similarly. The `g` is generated explicitly; the relevant source code (around line 240 of `builtin/describe.c`) is: ``` static void show_suffix(int depth, const unsigned char *sha1) { printf("-%d-g%s", depth, find_unique_abbrev(sha1, abbrev)); } ``` It's hard to search for information about this, because the relevant term, `g`, is a stopword. What's the `g` for?