* Stamp Git commit id into file during build process
@ 2010-01-16 18:50 Paul Richards
2010-01-16 19:14 ` Erik Faye-Lund
2010-01-16 19:35 ` Jakub Narebski
0 siblings, 2 replies; 10+ messages in thread
From: Paul Richards @ 2010-01-16 18:50 UTC (permalink / raw)
To: git
Hi,
I am in the process of migrating from Subversion to Git. One thing I
am unsure of is how to stamp the 'version' or 'commit id' into a file
as part of a build process.
With subversion I used the SubWCRev tool from TortoiseSVN
(http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html).
With Git I imagine that I'd like to put a copy of the current commit
id (either the full hash or a truncated version of that) into a file
which then gets included into the program source code in some way.
Is there a recommended way of doing this with git? Perhaps with
something similar to SubWCRev?
Currently I am thinking about using "git log", and grepping the output
in some way so that I just get the hash.
Thanks in advance,
--
Paul Richards
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 18:50 Stamp Git commit id into file during build process Paul Richards
@ 2010-01-16 19:14 ` Erik Faye-Lund
2010-01-16 19:15 ` Erik Faye-Lund
2010-01-16 19:17 ` Sverre Rabbelier
2010-01-16 19:35 ` Jakub Narebski
1 sibling, 2 replies; 10+ messages in thread
From: Erik Faye-Lund @ 2010-01-16 19:14 UTC (permalink / raw)
To: Paul Richards; +Cc: git
On Sat, Jan 16, 2010 at 7:50 PM, Paul Richards <paul.richards@gmail.com> wrote:
> Hi,
> I am in the process of migrating from Subversion to Git. One thing I
> am unsure of is how to stamp the 'version' or 'commit id' into a file
> as part of a build process.
>
> With subversion I used the SubWCRev tool from TortoiseSVN
> (http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html).
>
> With Git I imagine that I'd like to put a copy of the current commit
> id (either the full hash or a truncated version of that) into a file
> which then gets included into the program source code in some way.
>
> Is there a recommended way of doing this with git? Perhaps with
> something similar to SubWCRev?
>
> Currently I am thinking about using "git log", and grepping the output
> in some way so that I just get the hash.
>
I think you are looking for "git rev-parse HEAD". This outputs the
hash of HEAD as a single line on stdout. Or even better, you can use
the "git describe"-tool, which gives a nice and short description of
the commit relative to the most recent commit.
--
Erik "kusma" Faye-Lund
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 19:14 ` Erik Faye-Lund
@ 2010-01-16 19:15 ` Erik Faye-Lund
2010-01-16 19:17 ` Sverre Rabbelier
1 sibling, 0 replies; 10+ messages in thread
From: Erik Faye-Lund @ 2010-01-16 19:15 UTC (permalink / raw)
To: Paul Richards; +Cc: git
On Sat, Jan 16, 2010 at 8:14 PM, Erik Faye-Lund
<kusmabite@googlemail.com> wrote:
> the "git describe"-tool, which gives a nice and short description of
> the commit relative to the most recent commit.
>
...by "most recent commit", I mean "most recent tag". Sorry about that.
--
Erik "kusma" Faye-Lund
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 19:14 ` Erik Faye-Lund
2010-01-16 19:15 ` Erik Faye-Lund
@ 2010-01-16 19:17 ` Sverre Rabbelier
2010-01-16 19:22 ` Erik Faye-Lund
1 sibling, 1 reply; 10+ messages in thread
From: Sverre Rabbelier @ 2010-01-16 19:17 UTC (permalink / raw)
To: kusmabite; +Cc: Paul Richards, git
Heya,
On Sat, Jan 16, 2010 at 20:14, Erik Faye-Lund <kusmabite@googlemail.com> wrote:
> I think you are looking for "git rev-parse HEAD". This outputs the
> hash of HEAD as a single line on stdout. Or even better, you can use
> the "git describe"-tool, which gives a nice and short description of
> the commit relative to the most recent commit.
It would be better to have a look at gitattributes [0] instead.
[0] http://www.kernel.org/pub/software/scm/git/docs/gitattributes.html#_tt_ident_tt
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 19:17 ` Sverre Rabbelier
@ 2010-01-16 19:22 ` Erik Faye-Lund
2010-01-16 19:29 ` Sverre Rabbelier
0 siblings, 1 reply; 10+ messages in thread
From: Erik Faye-Lund @ 2010-01-16 19:22 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: Paul Richards, git
On Sat, Jan 16, 2010 at 8:17 PM, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> Heya,
>
> On Sat, Jan 16, 2010 at 20:14, Erik Faye-Lund <kusmabite@googlemail.com> wrote:
>> I think you are looking for "git rev-parse HEAD". This outputs the
>> hash of HEAD as a single line on stdout. Or even better, you can use
>> the "git describe"-tool, which gives a nice and short description of
>> the commit relative to the most recent commit.
>
> It would be better to have a look at gitattributes [0] instead.
>
Since he's looking for a replacement for SubWCRev (as opposed to
svn:keywords); not really.
--
Erik "kusma" Faye-Lund
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 19:22 ` Erik Faye-Lund
@ 2010-01-16 19:29 ` Sverre Rabbelier
0 siblings, 0 replies; 10+ messages in thread
From: Sverre Rabbelier @ 2010-01-16 19:29 UTC (permalink / raw)
To: kusmabite; +Cc: Paul Richards, git
Heya,
On Sat, Jan 16, 2010 at 20:22, Erik Faye-Lund <kusmabite@googlemail.com> wrote:
> Since he's looking for a replacement for SubWCRev (as opposed to
> svn:keywords); not really.
I misunderstood then, since he mentioned 'git log' and you mentioned
'git rev-parse HEAD', and I do not know what SubWCRev does.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 18:50 Stamp Git commit id into file during build process Paul Richards
2010-01-16 19:14 ` Erik Faye-Lund
@ 2010-01-16 19:35 ` Jakub Narebski
2010-01-16 21:12 ` Paul Richards
1 sibling, 1 reply; 10+ messages in thread
From: Jakub Narebski @ 2010-01-16 19:35 UTC (permalink / raw)
To: Paul Richards; +Cc: git
Paul Richards <paul.richards@gmail.com> writes:
> Hi,
> I am in the process of migrating from Subversion to Git. One thing I
> am unsure of is how to stamp the 'version' or 'commit id' into a file
> as part of a build process.
>
> With subversion I used the SubWCRev tool from TortoiseSVN
> (http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html).
>
> With Git I imagine that I'd like to put a copy of the current commit
> id (either the full hash or a truncated version of that) into a file
> which then gets included into the program source code in some way.
>
> Is there a recommended way of doing this with git? Perhaps with
> something similar to SubWCRev?
>
> Currently I am thinking about using "git log", and grepping the output
> in some way so that I just get the hash.
Not "git log".
Take a look how for example git project and Linux kernel use "git describe"
in GIT-VERSION-GEN script, and how they use GIT-VERSION-GEN script in the
Makefile.
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 19:35 ` Jakub Narebski
@ 2010-01-16 21:12 ` Paul Richards
2010-01-16 21:26 ` Shawn O. Pearce
2010-01-16 21:27 ` Jakub Narebski
0 siblings, 2 replies; 10+ messages in thread
From: Paul Richards @ 2010-01-16 21:12 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
2010/1/16 Jakub Narebski <jnareb@gmail.com>:
> Paul Richards <paul.richards@gmail.com> writes:
>
>> Hi,
>> I am in the process of migrating from Subversion to Git. One thing I
>> am unsure of is how to stamp the 'version' or 'commit id' into a file
>> as part of a build process.
>>
>> With subversion I used the SubWCRev tool from TortoiseSVN
>> (http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html).
>>
>> With Git I imagine that I'd like to put a copy of the current commit
>> id (either the full hash or a truncated version of that) into a file
>> which then gets included into the program source code in some way.
>>
>> Is there a recommended way of doing this with git? Perhaps with
>> something similar to SubWCRev?
>>
>> Currently I am thinking about using "git log", and grepping the output
>> in some way so that I just get the hash.
>
> Not "git log".
>
> Take a look how for example git project and Linux kernel use "git describe"
> in GIT-VERSION-GEN script, and how they use GIT-VERSION-GEN script in the
> Makefile.
>
Thanks, it appears though that "git describe" does not work in Cygwin git. :(
--
Paul Richards
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 21:12 ` Paul Richards
@ 2010-01-16 21:26 ` Shawn O. Pearce
2010-01-16 21:27 ` Jakub Narebski
1 sibling, 0 replies; 10+ messages in thread
From: Shawn O. Pearce @ 2010-01-16 21:26 UTC (permalink / raw)
To: Paul Richards; +Cc: git, Jakub Narebski
Paul Richards <paul.richards@gmail.com> wrote:
> > Take a look how for example git project and Linux kernel use "git describe"
> > in GIT-VERSION-GEN script, and how they use GIT-VERSION-GEN script in the
> > Makefile.
>
> Thanks, it appears though that "git describe" does not work in Cygwin git. :(
That's a serious bug. git describe should work fine on any system
Git itself runs on; its written in pure C and with the exception
of the --contains flag, doesn't rely on any external programs.
--
Shawn.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Stamp Git commit id into file during build process
2010-01-16 21:12 ` Paul Richards
2010-01-16 21:26 ` Shawn O. Pearce
@ 2010-01-16 21:27 ` Jakub Narebski
1 sibling, 0 replies; 10+ messages in thread
From: Jakub Narebski @ 2010-01-16 21:27 UTC (permalink / raw)
To: Paul Richards; +Cc: git
Dnia sobota 16. stycznia 2010 22:12, Paul Richards napisał:
> 2010/1/16 Jakub Narebski <jnareb@gmail.com>:
>> Paul Richards <paul.richards@gmail.com> writes:
>>> I am in the process of migrating from Subversion to Git. One thing I
>>> am unsure of is how to stamp the 'version' or 'commit id' into a file
>>> as part of a build process.
>> Take a look how for example git project and Linux kernel use "git describe"
>> in GIT-VERSION-GEN script, and how they use GIT-VERSION-GEN script in the
>> Makefile.
>
> Thanks, it appears though that "git describe" does not work in Cygwin git. :(
If you got something like
$ git describe
fatal: cannot describe 'a27cb622b30f18cb8510b7b3856d4029e617d95b'
it means that you don't have any tags in your history. You should tag your
releases (released versions) using annotated tags.
Anyway you have
$ git describe --always
a27cb62
--
Jakub Narebski
Poland
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-01-16 21:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-16 18:50 Stamp Git commit id into file during build process Paul Richards
2010-01-16 19:14 ` Erik Faye-Lund
2010-01-16 19:15 ` Erik Faye-Lund
2010-01-16 19:17 ` Sverre Rabbelier
2010-01-16 19:22 ` Erik Faye-Lund
2010-01-16 19:29 ` Sverre Rabbelier
2010-01-16 19:35 ` Jakub Narebski
2010-01-16 21:12 ` Paul Richards
2010-01-16 21:26 ` Shawn O. Pearce
2010-01-16 21:27 ` Jakub Narebski
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).