Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is possible automatic info about commit?

23 views
Skip to first unread message

Borneq

unread,
Jan 30, 2018, 4:30:44 PM1/30/18
to
If GnuC have macro that put to code info about current git commit hash?

Scott Lurndal

unread,
Jan 30, 2018, 4:49:57 PM1/30/18
to
Borneq <bor...@antyspam.hidden.pl> writes:
>If GnuC have macro that put to code info about current git commit hash?

gcc -DGIT_HASH=$(git rev-parse HEAD) source-file.c

Vir Campestris

unread,
Jan 30, 2018, 4:52:52 PM1/30/18
to
On 30/01/2018 21:30, Borneq wrote:
> If GnuC have macro that put to code info about current git commit hash?

Completely off-topic here. But you may be able to do it with a "git
commit hook".

Andy

Jorgen Grahn

unread,
Jan 31, 2018, 1:50:43 AM1/31/18
to
One has to be careful though, so you don't build source-file.o,
perform changes so that the hash changes (e.g. move to a different
branch), build with the old object file, and end up with a misleading
GIT_HASH in the executable.

I don't have a solution to that; nowadays I tend to think trying to do
what you want is a mistake. And it's also offtopic, since it's mostly
about the version control and build systems.

Also check out the gcc (or linker) BuildID feature (which I know very
little about).

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

David Brown

unread,
Jan 31, 2018, 3:12:30 AM1/31/18
to
On 30/01/18 22:30, Borneq wrote:
> If GnuC have macro that put to code info about current git commit hash?

I would recommend avoiding such things. When I check out code from a
repository and re-build, I want bit-for-bit identical builds. That way
I know everything is correct, everything works, there is no need for any
new testing or qualifications.

Different people and different types of programming have different
needs, of course - but you should consider carefully if this is really a
feature you want. It is easy to get things wrong, and impossible to
check that you always get it right.

<https://wiki.debian.org/ReproducibleBuilds>

0 new messages