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

Re: RCS keyword expansion

From
LHLars Hjemli <lh@elementstorage.no>
Date
Oct 12, 2007, 11:21 UTC
Message-ID
<8c5c35580710120421x130c5d7dt6c9d9b5a55313180@mail.gmail.com>
In-Reply-To
<Pine.LNX.4.64.0710121144001.3682@ds9.cixit.se>
On 10/12/07, Peter Karlsson <peter@softwolves.pp.se> wrote:
Show 8 quoted lines
> Johannes said:
> > So why not go for the contents?  With CVS/SVN you only have the
> > chance to do that by date or version number. With git, we have a more
> > powerful way: we do it by a hash of the contents.
>
> Yes, but the hash if of "everything". I'm not interested in
> "everything" in this context, and I don't want to have a separate git
> repository for each file...
Try this:

$ echo 'File revision $Id$' > index.html $ echo "*.html ident" > .gitattributes $ git add index.html .gitattributes $ git commit

>From now on, the '$Id' in index.html gets expanded to the SHA1 of the

content of index.html (not the commit SHA1) each time you checkout (and removed when you commit)

If you still want 'last modified date', the closest thing in git is 'commit date' which you can also get for free:

$ echo 'Last commit: $Format:%cd$' > index.html $ echo "*.html export-subst" > .gitattributes $ git add index.html .gitattributes $ git commit $ git archive --prefix=test/ HEAD | tar -x $ cat test/index.html

For all supported keywords, take a look at the 'git-log --pretty=format' option

-- larsh

Previous: Johannes SixtNext: Johannes Schindelin
Message 12 of 27 in “RCS keyword expansion”
  1. Peter KarlssonOct 11, 2007
  2. Johannes SixtOct 11, 2007
  3. Randal L. SchwartzOct 11, 2007
  4. Oliver KullmannOct 11, 2007
  5. Alex RiesenOct 11, 2007
  6. Johannes SchindelinOct 11, 2007
  7. Sam VilainOct 11, 2007
  8. Peter KarlssonOct 12, 2007
  9. Johannes SchindelinOct 12, 2007
  10. Peter KarlssonOct 12, 2007
  11. Johannes SixtOct 12, 2007
  12. Lars HjemliOct 12, 2007
  13. Johannes SchindelinOct 12, 2007
  14. Peter KarlssonOct 15, 2007
  15. Johannes SchindelinOct 15, 2007
  16. Jan HudecOct 12, 2007
  17. Salikh ZakirovOct 12, 2007
  18. Johannes SchindelinOct 12, 2007
  19. Zakirov SalikhOct 12, 2007
  20. Peter KarlssonOct 11, 2007
  21. Alex RiesenOct 11, 2007
  22. Peter KarlssonOct 12, 2007
  23. Barry FishmanOct 12, 2007
  24. Linus TorvaldsOct 12, 2007
  25. Florian WeimerOct 12, 2007
  26. Sam VilainOct 11, 2007
  27. Lars HjemliOct 11, 2007

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.