Thread (6 messages) flat view 6 messages, 3 authors, 2016-06-15

Re: How to embed a hash, tag or branch name?

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:47:08

Mikko Rapeli [off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help