git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Mikko Rapeli <mikko.rapeli@iki.fi>
Cc: git@vger.kernel.org
Subject: Re: How to embed a hash, tag or branch name?
Date: Fri, 31 Jul 2009 02:27:50 -0700 (PDT)	[thread overview]
Message-ID: <m3ljm5ryar.fsf@localhost.localdomain> (raw)
In-Reply-To: <20090731081723.GE29909@nalle>

Mikko Rapeli <mikko.rapeli@iki.fi> writes:

> How do I embed a hash, tag or branch name into source code managed by
> git?
> 
> I've tried searching the net, git manuals etc but haven't found a
> replacement for the old '$Id: $' strings from svn. What I need is a way to
> map compiled binaries and flash images to git tree heads, tags and
> branches.

You can embed SHA-1 of a _file contents_ (blob) using '$Id: $' keyword
with `ident` attribute - see gitattributes manpage.

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.


If you really, really, really need it, you can embed tag or branch
name into source code using `filter` attribute and custom clean/smudge
filters to do keyword un-expansion and keyword expansion.  But please
think twice about what you want to achive with keyword expansion, and
whether keyword expansion is a best solution...

-- 
Jakub Narebski
Poland
ShadeHawk on #git

  reply	other threads:[~2009-07-31  9:28 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 [this message]
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

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=m3ljm5ryar.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --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).