Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #144243

Re: Tagging programs with git hash. [slightly OT]

From Eli the Bearded <*@eli.users.panix.com>
Newsgroups comp.lang.c
Subject Re: Tagging programs with git hash. [slightly OT]
Date 2019-05-31 21:46 +0000
Organization Some absurd concept
Message-ID <eli$1905311746@qaz.wtf> (permalink)
References <dc2a28eb-b00b-4151-b7de-ede01ab3d373@googlegroups.com>

Show all headers | View raw


In comp.lang.c, Malcolm McLean  <malcolm.arthur.mclean@gmail.com> wrote:
> Git and similar version control systems have an internal version tag,
> in git it is the sha-1 hash, which is used to identify the version
> within the control system.
...
> But here we have a problem. The hash is created by applying a hash algorithm
> to the entire source, which is designed to change every digit of the hash
> if even a character of the source is changed. So if we add the hash to the
> source, we've changed the hash. So we can't tag an executable with its
> version number.

No, the hash isn't applied to the *entire* source. The hash is applied
to the entire history of the source that has been checked in.

Two crucial ways that differs:

1. If I have uncommitted changes, the value from
        git rev-parse --short HEAD
   or
	git log -1 --format="%H"
   as suggested else-thread, is a lie: it is the hash of the commited
   code, not the code compiled.

2. Generated code, put in .gitignore, will not be hashed.

Using a hash function to create generated code with the hash value of
the source is the obvious fix. Also including the git SHA-1 if available
will be useful for tracking major releases. When the git SHA-1 matches a
known commit on the origin, a similar compile-time generated hash should
also match (in the sense of being correllated, not being the same).

But an instance separated from the git history can still have that
second hash be exactly the same as one generated from the origin source
at some stage (naive copies of source code, or code compiled with
changes that are not commited, but will be in origin in the future). And
code where the generated hash matches nothing else become immediately
suspect for any sort of bug report.

There is a little bit of fragility in making sure that the generated
hash includes all of the code that is compiled into a project, while not
accidentally including other code that might be in the same directory.

Elijah
------
yacc generated C code is, eg, something that may need to be avoided

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Tagging programs with git hash. [slightly OT] Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-05-31 07:02 -0700
  Re: Tagging programs with git hash. [slightly OT] queequeg@trust.no1 (Queequeg) - 2019-05-31 14:27 +0000
    Re: Tagging programs with git hash. [slightly OT] Mateusz Viste <mateusz@wont.tell> - 2019-05-31 16:42 +0000
      Re: Tagging programs with git hash. [slightly OT] Keith Thompson <kst-u@mib.org> - 2019-05-31 13:23 -0700
      Re: Tagging programs with git hash. [slightly OT] queequeg@trust.no1 (Queequeg) - 2019-05-31 21:10 +0000
        Re: Tagging programs with git hash. [slightly OT] Mateusz Viste <mateusz@wont.tell> - 2019-06-01 09:31 +0000
          Re: Tagging programs with git hash. [slightly OT] queequeg@trust.no1 (Queequeg) - 2019-06-01 12:39 +0000
  Re: Tagging programs with git hash. [slightly OT] David Brown <david.brown@hesbynett.no> - 2019-05-31 16:28 +0200
  Re: Tagging programs with git hash. [slightly OT] fir <profesor.fir@gmail.com> - 2019-05-31 07:51 -0700
  Re: Tagging programs with git hash. [slightly OT] Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-05-31 15:59 +0100
    Re: Tagging programs with git hash. [slightly OT] Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-05-31 22:56 +0100
      Re: Tagging programs with git hash. [slightly OT] John Forkosh <forkosh@panix.com> - 2019-06-01 02:55 +0000
        Re: Tagging programs with git hash. [slightly OT] fir <profesor.fir@gmail.com> - 2019-06-01 04:26 -0700
          Re: Tagging programs with git hash. [slightly OT] fir <profesor.fir@gmail.com> - 2019-06-01 04:35 -0700
      Re: Tagging programs with git hash. [slightly OT] Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-06-01 04:03 -0700
  Re: Tagging programs with git hash. [slightly OT] "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-05-31 13:30 -0700
  Re: Tagging programs with git hash. [slightly OT] Eli the Bearded <*@eli.users.panix.com> - 2019-05-31 21:46 +0000
  Re: Tagging programs with git hash. [slightly OT] Shuggie <shuggie@latepaul.com> - 2019-06-01 11:21 +0100
  Re: Tagging programs with git hash. [slightly OT] Ike Naar <ike@iceland.freeshell.org> - 2019-06-01 21:23 +0000
    Re: Tagging programs with git hash. [slightly OT] Keith Thompson <kst-u@mib.org> - 2019-06-01 14:34 -0700
    Re: Tagging programs with git hash. [slightly OT] Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-06-02 12:36 -0700
      Re: Tagging programs with git hash. [slightly OT] Keith Thompson <kst-u@mib.org> - 2019-06-02 14:35 -0700

csiph-web