[Gambas-user] Why are the gitlab master and "system info" versions different?

Tobias Boege tobs at taboege.de
Wed Jan 26 22:34:00 CET 2022

On Wed, 26 Jan 2022, Martin Belmonte wrote:
> El 26/1/22 a las 17:19, Benoît Minisini escribió:
> > 
> > As it is too long, gitlab only displays the eight first digits, whereas
> > the git tools displays the seven first digits.
> OK, I understand.
> So the gambas IDE truncates into 7 characters what git gives [1], which is
> the full hash.
> But if you using [2] that gives the 7 char short version (that you say
> right?)
> [1] git rev-parse HEAD
> [2] git log --pretty=format:'%h' -n 1
> So, if it's not too much work since it's not that important either, it's
> just to make it more user friendly and see the same code everywhere, change
> the IDE to truncates the same as this in 8 characters.

What the Gambas build process does, more precisely, is invoke
`git rev-parse --short HEAD`. This leaves it up to git's judgement
to how many characters the commit hash is shortened. According to
the manpages, git computes this number depending on the size of the
repository and a tradeoff between a shorter abbreviation and a higher
chance that the number is unique and will stay unique "for some time".

On my local machine, I get 9-digit abbreviations, presumably because
either my version of git has different sensitivities or because my
repository is larger than yours (I have a number of branches from
multiple remote sources stored locally).

Instead of matching gitlab's current choice of 8 characters, it seems
more robust to me to trust git's built-in judgement about the length.
The commit hash (and branch name) were added to the version output of
Gambas to help developers make sure that they are not running a stale
version of Gambas because they forgot to `make install` and to make
bug reports for unstable versions automatically more precise. Both of
these goals need the commit hash prefix to be unique only in a rather
limited timeframe and `git rev-parse --short` does a good job ensuring
that without hardcoded numbers.

If you really want 8 characters because you work with the gitlab UI
a lot, I suggest you change your local git configuration to match it:

  $ git config core.abbrev 8


"There's an old saying: Don't change anything... ever!" -- Mr. Monk

More information about the User mailing list