Referencing git commit in the comment of Bugzilla

Adriaan de Groot adridg at freebsd.org
Fri Feb 5 11:04:43 UTC 2021


On Friday, 5 February 2021 01:46:44 CET Yasuhiro Kimura wrote:
> Doc and src have already migrated to git and ports will follow soon.
> In this situation it's quite possbile that bug reporter wants to
> reference git commit in the comment of bug report submitted to
> Bugzilla. Then is there standard(?) way to do it? As for subversion
> syntax such as "base r123456" or "ports r778899" is provided. And I
> expect similar one is provided for git.

Since a "git commit" has a hash, there is no nice number-that-always-goes-up 
to specify a commit; there **is** the hash, though, which might be

b8a9c4c3b78aa58e289dd9212f399e3f6af690b0

That is a long and annoying string, and since *usually* there are no 
collisions, git provides "short hash" notation: a unique prefix of the commit 
hash is enough. In the specific repository I'm working in,

b8a9c4c3b

is enough: 9 characters instead of 40. In a different repo (FreeBSD ports, as 
it happens), asking for a short hash (of a different commit) gives me

be24aaa957c8

so 12 characters. The commit before that one was

ef537e763f17

which shows there is no nice number-that-always-goes-up property.


To get the hash, use (for instance) `git log -1`; to get the shorter one, use 
`git log -1 --abbrev-commit`. You could add an alias ("slog", for short-log) 
adding `--abbrev-commit` if you always want to see the short hash; do note 
that the short hash can become *longer* later in history if a prefix collision 
does happen.

[ade]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freebsd.org/pipermail/freebsd-git/attachments/20210205/1b6d6402/attachment.sig>


More information about the freebsd-git mailing list