git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Something like $Id$, $Revision$ or $Date$?

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 10, 2008, 20:17 UTC
Message-ID
<200811102117.30372.jnareb@gmail.com>
In-Reply-To
<871vxjl5af.fsf@erwin.mina86.com>
Michal Nazarewicz wrote:
Show 25 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
>> Dnia poniedziałek 10. listopada 2008 18:38, Michal Nazarewicz napisał:
>>> Jakub Narebski <jnareb@gmail.com> writes:
>>> 
>>>> 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. 
>>> 
>>> In my case identifying content not commit would be even better.
>>
>> Well, in that case using `ident` attribute would be enough
>> (but cryptic).
> 
> Yes, but it forces me to do some voodoo magic (ie. checkout) to get the
> Id in the file, ;) like so:
> 
> #v+
> $ echo '$Id$'>bar && git add bar && git commit -m 'Added bar' && cat bar
> Created commit d49d436: Added bar
>  1 files changed, 1 insertions(+), 0 deletions(-)
>  create mode 100644 bar
> $Id$
> $ rm bar && git checkout bar && cat bar
> $Id: 055c8729cdcc372500a08db659c045e16c4409fb $
> #v-

Well, _some_ command has to be invoked to expand keywords. "git add" doesn't do that (perhaps it should?), so you need to use checkout.

And checkout doesn't touch file if it is identical, so you need to remove it first; nevertheless you don't need to use commit in betwen, as "git checkout bar" would checkout file out of index (you added contents of file to index with "git add bar").

-- 
Jakub Narebski
Poland
Previous: Michal NazarewiczNext: Francis Galiegue
Message 15 of 18 in “Something like $Id$, $Revision$ or $Date$?”
  1. Michal NazarewiczNov 10, 2008
  2. Sverre RabbelierNov 10, 2008
  3. Michal NazarewiczNov 10, 2008
  4. dhruvaNov 10, 2008
  5. Michal NazarewiczNov 10, 2008
  6. Johannes SixtNov 10, 2008
  7. Johannes SchindelinNov 10, 2008
  8. dhruvaNov 10, 2008
  9. Michal NazarewiczNov 10, 2008
  10. Francis GaliegueNov 10, 2008
  11. Jakub NarebskiNov 10, 2008
  12. Michal NazarewiczNov 10, 2008
  13. Jakub NarebskiNov 10, 2008
  14. Michal NazarewiczNov 10, 2008
  15. Jakub NarebskiNov 10, 2008
  16. Francis GaliegueNov 10, 2008
  17. Jakub NarebskiNov 10, 2008
  18. Brian GernhardtNov 10, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.