From: Jakub Narebski <jnareb@gmail.com>
To: Michal Nazarewicz <mina86@tlen.pl>
Cc: git@vger.kernel.org
Subject: Re: Something like $Id$, $Revision$ or $Date$?
Date: Mon, 10 Nov 2008 07:59:33 -0800 (PST) [thread overview]
Message-ID: <m3iqqvefmo.fsf@localhost.localdomain> (raw)
In-Reply-To: <87ljvsjuq7.fsf@erwin.mina86.com>
Michal Nazarewicz <mina86@tlen.pl> writes:
> Hello,
>
> as probably many of you know CVS supported some magic tags which were
> replaced in committed files to a predefined value. For instance, if
> there was a "$Revision$" string in a file it would get replaced with
> "$Revision: x.y $" (or "$Revision: x.y.z.w $" and so on) where "x.y" is
> file's revision number.
>
> Now, what I need is such feature in GIT. Upon committing I would like
> some magic string (say "$Date$") to be replaced with some value
> identifying uniquely given version of a file (a date of the commit would
> be sufficient).
>
> I tried using some hooks for it but couldn't came up with anything that
> would actually work.
Well, there is `ident` attribute which you can set in .gitattributes
file which would make git do $Id$ keyword expansion. However the $Id$
git uses is not something you are familiar with: it is 40-character
hexadecimal blob object name. With it you can find (try to find)
relevant commit.
The reason why git doesn't support keywords like $Revision$ or $Date$
is performance: the $Revision$ and $Date$ are keywords related to
_commit_ data, not blob data. You can have the same contents of the
file in two different branches, thus two different commits, thus two
different $Revision$ or $Date$. If contents of file didn't change
between branches, git doesn't touch the file, which results in much
faster branch switching, for example (and also faster committing).
What you can do is one of the following things:
1. You can try to use either hooks (post-commit, post-update I think)
or smudge / clean filters (via gitattributes) to do keyword
expansion. This hits performance, and you probably would have the
problems CVS ad with keyword expansion.
2. You can use `export-subst` gitattribute and make git-archive do
keyword expansion, which can include things like '$Format:%aD$'
for commit date (equivalent of $Date:$?).
3. You can run some local equivalent of GIT-VERSION-GEN script git
and Linux kernel uses, and make your build system (Makefile)
replace '@@VERSION@@' or '++VERSION++' keywords / placeholders
as part of compiling process.
HTH
--
Jakub Narębski
Poland
ShadeHawk on #git
next prev parent reply other threads:[~2008-11-10 16:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-10 0:22 Something like $Id$, $Revision$ or $Date$? Michal Nazarewicz
2008-11-10 0:43 ` Sverre Rabbelier
2008-11-10 1:16 ` Michal Nazarewicz
2008-11-10 3:43 ` dhruva
2008-11-10 9:49 ` Michal Nazarewicz
2008-11-10 7:26 ` Johannes Sixt
2008-11-10 12:25 ` Johannes Schindelin
2008-11-10 14:05 ` dhruva
2008-11-10 15:48 ` Michal Nazarewicz
2008-11-10 15:58 ` Francis Galiegue
2008-11-10 15:59 ` Jakub Narebski [this message]
2008-11-10 17:38 ` Michal Nazarewicz
2008-11-10 18:03 ` Jakub Narebski
2008-11-10 20:00 ` Michal Nazarewicz
2008-11-10 20:17 ` Jakub Narebski
2008-11-10 20:24 ` Francis Galiegue
2008-11-10 20:32 ` Jakub Narebski
2008-11-10 20:58 ` Brian Gernhardt
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=m3iqqvefmo.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=mina86@tlen.pl \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.