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

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

From
Brian Gernhardt <benji@silverinsanity.com>
Date
Nov 10, 2008, 20:58 UTC
Message-ID
<866D073C-57B9-457E-80BA-0C87B6D14E23@silverinsanity.com>
In-Reply-To
<200811102132.05472.jnareb@gmail.com>
On Nov 10, 2008, at 3:32 PM, Jakub Narebski wrote:
Show 23 quoted lines
> Dnia poniedziałek 10. listopada 2008 21:24, Francis Galiegue  
> napisał:
>> Le Monday 10 November 2008 21:17:29 Jakub Narebski, vous avez  
>> écrit :
>
>>> 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.
>>>
>>
>> If "git add" aims to do that, you'd have to be very, VERY careful,  
>> not to
>> substitute in the wrong place to start with, not to attempt  
>> substitution in
>> binary files...
>>
>> And this would have a sizeable cost, imho. If you really want to do  
>> this,
>> isn't there a hook somewhere that can do that for you, instead of  
>> modifying
>> git add directly?
>
> If I remember correctly there was idea to add 'pre-add' or 'post-add'
> hook...

Without adding any additional hooks, you could use the post-commit hook to look for any added/changed files containing $Id$ lines and force a checkout of them.

Perhaps something as simple as the following in your .git/hooks/post- commit (untested, caveat emptor, YMMV):

git diff --name-only --diff-filter=AM HEAD^ HEAD | \
while read file; do
   rm "$file" && git checkout -- "$file"
end
~~ Brian
Previous: Jakub Narebski
Message 18 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.