git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Dirk Süsserott" <newsletter@dirk.my1.cc>
To: Jakub Narebski <jnareb@gmail.com>
Cc: "Dirk Süsserott" <newsletter@dirk.my1.cc>,
	"Mikko Rapeli" <mikko.rapeli@iki.fi>,
	git@vger.kernel.org
Subject: Re: How to embed a hash, tag or branch name?
Date: Sat, 01 Aug 2009 18:04:58 +0200	[thread overview]
Message-ID: <4A7467AA.7060400@dirk.my1.cc> (raw)
In-Reply-To: <200908011513.13016.jnareb@gmail.com>

Am 01.08.2009 15:13 schrieb Jakub Narebski:
> On Sat, 1 August 2009, Dirk Süsserott wrote:
>> Am 31.07.2009 11:52 schrieb Mikko Rapeli:
>>> On Fri, Jul 31, 2009 at 02:27:50AM -0700, Jakub Narebski wrote:
> 
>>>> You can embed SHA-1 of a _file contents_ (blob) using '$Id: $' keyword
>>>> with `ident` attribute - see gitattributes manpage.
>>> Great, thanks!
>>>
>>>> The correct solution of embedding version number is to do it at 
>>>> _build time_, using e.g. script similar to GIT-VERSION-GEN used by
>>>> Git itself and by Linux kernel.  It helps if you tag your releases.
>> Hi Mikko,
>>
>> I don't know whether you want to use the "ident" command on your final
>> binary. With Git, that's pointless, as all source files will have the
>> same $Id$. So it's perfectly sufficient to have only ONE file enriched
>> with Git's SHA1.
> 
> You are wrong.  In Git $Id$ / $Id: $ expands to SHA-1 id of _blob_ 
> (i.e. of file *contents*), not SHA-1 id of a commit.  This way when
> switching branches or rewinding branch using git-reset we don't have
> to pay huge performance penalty because of `ident`, as we would have
> because every file would have to be changed if $Id$ was about commit
> id (or if there was $Revision$ or $Author$ implemented).

Ok, sorry about that. Actually I haven't read the concerning docs
*that* well when I figured out that keyword expansion with Git
is not exactly a good idea.

> 
>> Suggestion: During build time, compile (and link in) a file (e.g.
>> version.c) with "-DVERSION=\"$(git describe)\"". My version.c looks like
>> this:
> 
> GIT-VERSION-GEN and various tricks in Makefile do just that, not only
> for compiled parts, but also for scripts.
> 

Right, but my explanation shows the overall intention of that.
So, Mikko, have a look at GIT-VERSION-GEN and my suggestion and
use some kind of summary of them.

      reply	other threads:[~2009-08-01 16:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-31  8:17 How to embed a hash, tag or branch name? Mikko Rapeli
2009-07-31  9:27 ` Jakub Narebski
2009-07-31  9:52   ` Mikko Rapeli
2009-08-01 12:38     ` Dirk Süsserott
2009-08-01 13:13       ` Jakub Narebski
2009-08-01 16:04         ` Dirk Süsserott [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A7467AA.7060400@dirk.my1.cc \
    --to=newsletter@dirk.my1.cc \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=mikko.rapeli@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).