{"thread":{"id":"16245","subject":"Something like $Id$, $Revision$ or $Date$?","startedAt":"2008-11-10T00:22:08Z","lastAt":"2008-11-10T20:58:35Z","messageCount":18,"participants":["Michal Nazarewicz","Sverre Rabbelier","dhruva","Johannes Sixt","Johannes Schindelin","Francis Galiegue","Jakub Narebski","Brian Gernhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"95294","messageId":"87ljvsjuq7.fsf@erwin.mina86.com","threadId":"16245","inReplyTo":null,"subject":"Something like $Id$, $Revision$ or $Date$?","fromName":"Michal Nazarewicz","fromEmail":"mina86@tlen.pl","sentAt":"2008-11-10T00:22:08Z","receivedAt":"2008-11-10T00:22:08Z","isPatch":false,"sender":{"key":"mina86@tlen.pl","avatar":"https://gravatar.com/avatar/55cbb4a7b7565c687a33afaee923bd3c05c46172519476bb1365631822278923?d=mp&s=160"},"body":"Hello,\n\nas probably many of you know CVS supported some magic tags which were\nreplaced in committed files to a predefined value.  For instance, if\nthere was a \"$Revision$\" string in a file it would get replaced with\n\"$Revision: x.y $\" (or \"$Revision: x.y.z.w $\" and so on) where \"x.y\" is\nfile's revision number.\n\nNow, what I need is such feature in GIT.  Upon committing I would like\nsome magic string (say \"$Date$\") to be replaced with some value\nidentifying uniquely given version of a file (a date of the commit would\nbe sufficient).\n\nI tried using some hooks for it but couldn't came up with anything that\nwould actually work.\n\n-- \nBest regards,                                         _     _\n .o. | Liege of Serenly Enlightened Majesty of      o' \\,=./ `o\n ..o | Computer Science,  Michal \"mina86\" Nazarewicz   (o o)\n ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--\n"},{"id":"95296","messageId":"bd6139dc0811091643m31ff6f49o55a4c581be7f38b2@mail.gmail.com","threadId":"16245","inReplyTo":"87ljvsjuq7.fsf@erwin.mina86.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-11-10T00:43:41Z","receivedAt":"2008-11-10T00:43:41Z","isPatch":false,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Mon, Nov 10, 2008 at 01:22, Michal Nazarewicz <mina86@tlen.pl> wrote:\n> Now, what I need is such feature in GIT.  Upon committing I would like\n> some magic string (say \"$Date$\") to be replaced with some value\n> identifying uniquely given version of a file (a date of the commit would\n> be sufficient).\n\nPlease have a look at the relevant entry in the faq [0].\n\n[0] http://git.or.cz/gitwiki/GitFaq#head-4a0afe71a2bb7734777a8b0b345e0308aefdbd40\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"95298","messageId":"87hc6gjs7v.fsf@erwin.mina86.com","threadId":"16245","inReplyTo":"bd6139dc0811091643m31ff6f49o55a4c581be7f38b2@mail.gmail.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Michal Nazarewicz","fromEmail":"mina86@tlen.pl","sentAt":"2008-11-10T01:16:20Z","receivedAt":"2008-11-10T01:16:20Z","isPatch":false,"sender":{"key":"mina86@tlen.pl","avatar":"https://gravatar.com/avatar/55cbb4a7b7565c687a33afaee923bd3c05c46172519476bb1365631822278923?d=mp&s=160"},"body":"\"Sverre Rabbelier\" <alturin@gmail.com> writes:\n\n> On Mon, Nov 10, 2008 at 01:22, Michal Nazarewicz <mina86@tlen.pl> wrote:\n>> Now, what I need is such feature in GIT.  Upon committing I would like\n>> some magic string (say \"$Date$\") to be replaced with some value\n>> identifying uniquely given version of a file (a date of the commit would\n>> be sufficient).\n>\n> Please have a look at the relevant entry in the faq [0].\n>\n> [0] http://git.or.cz/gitwiki/GitFaq#head-4a0afe71a2bb7734777a8b0b345e0308aefdbd40\n\nThanks for the quick reply (and yes, I can't believe I couldn't find\nthat myself...) but it still lacks one thing that I'd like to have.\nI would like the \"$Id$\" sequences to be updated automatically after\na commit (ie. without the need to check out).  (Besides I would prefer\n$Date$ more but I can live with $Id$ I guess ;) ).\n\n-- \nBest regards,                                         _     _\n .o. | Liege of Serenly Enlightened Majesty of      o' \\,=./ `o\n ..o | Computer Science,  Michal \"mina86\" Nazarewicz   (o o)\n ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--\n"},{"id":"95300","messageId":"e3f230850811091943k63e4a93n566402458a6947dd@mail.gmail.com","threadId":"16245","inReplyTo":"87hc6gjs7v.fsf@erwin.mina86.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"dhruva","fromEmail":"dhruvakm@gmail.com","sentAt":"2008-11-10T03:43:04Z","receivedAt":"2008-11-10T03:43:04Z","isPatch":false,"sender":{"key":"dhruvakm@gmail.com","avatar":"https://gravatar.com/avatar/96fe022a95b60fd0de7f9f521364d964cdc7c46be5cfef279f8d4379e49e19a6?d=mp&s=160"},"body":"Hi,\n\nOn Mon, Nov 10, 2008 at 6:46 AM, Michal Nazarewicz <mina86@tlen.pl> wrote:\n> \"Sverre Rabbelier\" <alturin@gmail.com> writes:\n>\n>> On Mon, Nov 10, 2008 at 01:22, Michal Nazarewicz <mina86@tlen.pl> wrote:\n>>> Now, what I need is such feature in GIT.  Upon committing I would like\n>>> some magic string (say \"$Date$\") to be replaced with some value\n>>> identifying uniquely given version of a file (a date of the commit would\n>>> be sufficient).\n>>\n>> Please have a look at the relevant entry in the faq [0].\n>>\n>> [0] http://git.or.cz/gitwiki/GitFaq#head-4a0afe71a2bb7734777a8b0b345e0308aefdbd40\n>\n> Thanks for the quick reply (and yes, I can't believe I couldn't find\n> that myself...) but it still lacks one thing that I'd like to have.\n> I would like the \"$Id$\" sequences to be updated automatically after\n> a commit (ie. without the need to check out).  (Besides I would prefer\n> $Date$ more but I can live with $Id$ I guess ;) ).\n\nI have worked on this topic quite a bit to fix issues in git-p4. There\nis no direct way to get this $Id$ expansion in git, however you can\nuse a simple pre-commit hook (alpha state, more a proof of concept\nthat happens to work for me)\n\n#!/usr/bin/env bash\n\nfor file in `git diff-index --name-only --diff-filter=AM HEAD` ; do\n        perl -pi -e 's/(\\$[ \\t]*Id)(.*)([ \\t]*\\$)/\"\\$Id: git\n\".time().\" \\$\"/e' ${file}\n        git add ${file} > /dev/null\ndone\n\n-dhruva\n\n-- \nContents reflect my personal views only!\n"},{"id":"95307","messageId":"4917E240.1060409@viscovery.net","threadId":"16245","inReplyTo":"87hc6gjs7v.fsf@erwin.mina86.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-11-10T07:26:56Z","receivedAt":"2008-11-10T07:26:56Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Michal Nazarewicz schrieb:\n> (Besides I would prefer\n> $Date$ more but I can live with $Id$ I guess ;) ).\n\nJust FYI: The $Id$ that git produces is completely different from what CVS\nproduces and probably not what you expect: 'man gitattributes'\n\n-- Hannes\n"},{"id":"95316","messageId":"8763mvoqqc.fsf@erwin.mina86.com","threadId":"16245","inReplyTo":"e3f230850811091943k63e4a93n566402458a6947dd@mail.gmail.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Michal Nazarewicz","fromEmail":"mina86@tlen.pl","sentAt":"2008-11-10T09:49:31Z","receivedAt":"2008-11-10T09:49:31Z","isPatch":false,"sender":{"key":"mina86@tlen.pl","avatar":"https://gravatar.com/avatar/55cbb4a7b7565c687a33afaee923bd3c05c46172519476bb1365631822278923?d=mp&s=160"},"body":"> On Mon, Nov 10, 2008 at 6:46 AM, Michal Nazarewicz <mina86@tlen.pl> wrote:\n>> I would like the \"$Id$\" sequences to be updated automatically after\n>> a commit (ie. without the need to check out).\n\ndhruva <dhruvakm@gmail.com> writes:\n> There is no direct way to get this $Id$ expansion in git, however you\n> can use a simple pre-commit hook (alpha state, more a proof of concept\n> that happens to work for me)\n>\n> #!/usr/bin/env bash\n>\n> for file in `git diff-index --name-only --diff-filter=AM HEAD` ; do\n>         perl -pi -e 's/(\\$[ \\t]*Id)(.*)([ \\t]*\\$)/\"\\$Id: git\n> \".time().\" \\$\"/e' ${file}\n>         git add ${file} > /dev/null\n> done\n\nIn fact the following works just as well:\n\n#v+\nfiles=$(git diff-index --name-only --diff-filter=AM HEAD)\nperl -pi -e 's/\\$\\s*Id.*?\\$/\\$Id: git '$(TZ=UTC date +%s)' \\$/g' $files\ngit add $files\n#v-\n\nBut then again, it has two unpleasant side effects: (i) all modified\nfiles are added and (ii) if I abort a commit the file stays modified.\n(i) can be fixed by removing \"git add\" but then again (iii) even files\nwhich are not committed will be modified.\n\n-- \nBest regards,                                         _     _\n .o. | Liege of Serenly Enlightened Majesty of      o' \\,=./ `o\n ..o | Computer Science,  Michal \"mina86\" Nazarewicz   (o o)\n ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--\n"},{"id":"95335","messageId":"alpine.DEB.1.00.0811101319570.30769@pacific.mpi-cbg.de","threadId":"16245","inReplyTo":"87hc6gjs7v.fsf@erwin.mina86.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-11-10T12:25:14Z","receivedAt":"2008-11-10T12:25:14Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 10 Nov 2008, Michal Nazarewicz wrote:\n\n> I would like the \"$Id$\" sequences to be updated automatically after a \n> commit (ie. without the need to check out).  (Besides I would prefer \n> $Date$ more but I can live with $Id$ I guess ;) ).\n\nNo, you don't.\n\nAt least most likely you do not want that behavior.  Typically, you have \nthe $Id$ stuff in released versions to indicate what revision that version \ncame from even if the files are no longer in a Git repository.\n\nAnd you can have that without ever committing anything in-between, by \nusing the export-subst attributes with git-archive.  Have a look at \nDocumentation/gitattributes.txt (I agree it is underdocumented in \ngit-archive.txt).\n\nIf that is not your use case, then it may be wise to let us Git people \nknow what you _actually_ want (i.e. instead of asking for a specific \nsolution, you could tell us what your problem is).\n\nCiao,\nDscho\n"},{"id":"95336","messageId":"e3f230850811100605u75eb811bidb8f36f62c3673ce@mail.gmail.com","threadId":"16245","inReplyTo":"alpine.DEB.1.00.0811101319570.30769@pacific.mpi-cbg.de","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"dhruva","fromEmail":"dhruvakm@gmail.com","sentAt":"2008-11-10T14:05:24Z","receivedAt":"2008-11-10T14:05:24Z","isPatch":false,"sender":{"key":"dhruvakm@gmail.com","avatar":"https://gravatar.com/avatar/96fe022a95b60fd0de7f9f521364d964cdc7c46be5cfef279f8d4379e49e19a6?d=mp&s=160"},"body":"Hi,\n\nOn Mon, Nov 10, 2008 at 5:55 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> If that is not your use case, then it may be wise to let us Git people\n> know what you _actually_ want (i.e. instead of asking for a specific\n> solution, you could tell us what your problem is).\n\nSince you have opened this topic to make a request with the problem, I\nhave a problem for which I need $Id$ expansion.\n\nThe git-p4 tool does not record contents in $Id$. When I try to submit\nfrom git to p4 using git-p4, it does a 'p4 sync' which brings in\nmodified files with $Id$ changes. When git-p4 tries to apply patches,\nit would not have recorded the change in $Id$. If there was a\nmechanism to make $Id$ change and tracked in git, it would have\nrecorded a change as a hunk and the patch would have applied cleanly.\nI have posted this problem earlier and also on the #git channel. Hope\nto see some traction.\n\nwith best regards,\ndhruva\n\n-- \nContents reflect my personal views only!\n"},{"id":"95339","messageId":"871vxjoa3j.fsf@erwin.mina86.com","threadId":"16245","inReplyTo":"alpine.DEB.1.00.0811101319570.30769@pacific.mpi-cbg.de","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Michal Nazarewicz","fromEmail":"mina86@tlen.pl","sentAt":"2008-11-10T15:48:48Z","receivedAt":"2008-11-10T15:48:48Z","isPatch":false,"sender":{"key":"mina86@tlen.pl","avatar":"https://gravatar.com/avatar/55cbb4a7b7565c687a33afaee923bd3c05c46172519476bb1365631822278923?d=mp&s=160"},"body":"> On Mon, 10 Nov 2008, Michal Nazarewicz wrote:\n>> I would like the \"$Id$\" sequences to be updated automatically after a \n>> commit (ie. without the need to check out).  (Besides I would prefer \n>> $Date$ more but I can live with $Id$ I guess ;) ).\n\nJohannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> No, you don't.\n>\n> At least most likely you do not want that behavior.  Typically, you have \n> the $Id$ stuff in released versions to indicate what revision that version \n> came from even if the files are no longer in a Git repository.\n>\n> And you can have that without ever committing anything in-between, by \n> using the export-subst attributes with git-archive.  Have a look at \n> Documentation/gitattributes.txt (I agree it is underdocumented in \n> git-archive.txt).\n\nThe thing is that for some repositories I don't distinguish anything\nlike a \"release version\" of files.  For instance, I have a repository\nwith my configuration files, and I want to be able to do\n\n  scp emacs system-where-git-is-not-installed:.emacs\n\nor attaching the file in an email without worrying about anything.\nInstead, what you're describing would force me to do some voodoo magic\npriory to sending the file.\n\n-- \nBest regards,                                         _     _\n .o. | Liege of Serenly Enlightened Majesty of      o' \\,=./ `o\n ..o | Computer Science,  Michal \"mina86\" Nazarewicz   (o o)\n ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--\n"},{"id":"95341","messageId":"200811101658.44366.fg@one2team.net","threadId":"16245","inReplyTo":"871vxjoa3j.fsf@erwin.mina86.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Francis Galiegue","fromEmail":"fg@one2team.net","sentAt":"2008-11-10T15:58:44Z","receivedAt":"2008-11-10T15:58:44Z","isPatch":false,"sender":{"key":"fg@one2team.net","avatar":null},"body":"Le Monday 10 November 2008 16:48:48 Michal Nazarewicz, vous avez écrit :\n[...]\n>\n> The thing is that for some repositories I don't distinguish anything\n> like a \"release version\" of files.\n\n\"Git tracks contents, not files\".\n\nYou have two problems here:\n* first, unlike CVS, files don't have revisions;\n* second, unline SVN (or even Mercurial), commits are not \"ordered\", at least \nnot in a natural way (can't tell what SHA1 is more recent).\n\nGit will not track a single file, and I don't think it will ever do so. And \nthen, what about renames?\n\nYou have two options there:\n\n1. (requires git modification, I guess) put a $last_modified_date$ magic that \nexpands to the last modification date;\n2. (what I do) keep an internal ChangeLog for such files, that you (have to) \nfill by hand each time.\n\nThe second approach has big advantages:\n* you can date your changes;\n* you _really_ know the file history;\n* git's renaming handle allows you to track this ChangeLog over time!\n\nIt requires discipline, though...\n\n-- \nfge\n"},{"id":"95342","messageId":"m3iqqvefmo.fsf@localhost.localdomain","threadId":"16245","inReplyTo":"87ljvsjuq7.fsf@erwin.mina86.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-11-10T15:59:33Z","receivedAt":"2008-11-10T15:59:33Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Michal Nazarewicz <mina86@tlen.pl> writes:\n\n> Hello,\n> \n> as probably many of you know CVS supported some magic tags which were\n> replaced in committed files to a predefined value.  For instance, if\n> there was a \"$Revision$\" string in a file it would get replaced with\n> \"$Revision: x.y $\" (or \"$Revision: x.y.z.w $\" and so on) where \"x.y\" is\n> file's revision number.\n> \n> Now, what I need is such feature in GIT.  Upon committing I would like\n> some magic string (say \"$Date$\") to be replaced with some value\n> identifying uniquely given version of a file (a date of the commit would\n> be sufficient).\n> \n> I tried using some hooks for it but couldn't came up with anything that\n> would actually work.\n\nWell, there is `ident` attribute which you can set in .gitattributes\nfile which would make git do $Id$ keyword expansion. However the $Id$\ngit uses is not something you are familiar with: it is 40-character\nhexadecimal blob object name. With it you can find (try to find)\nrelevant commit.\n\nThe reason why git doesn't support keywords like $Revision$ or $Date$\nis performance: the $Revision$ and $Date$ are keywords related to\n_commit_ data, not blob data. You can have the same contents of the\nfile in two different branches, thus two different commits, thus two\ndifferent $Revision$ or $Date$. If contents of file didn't change\nbetween branches, git doesn't touch the file, which results in much\nfaster branch switching, for example (and also faster committing).\n\nWhat you can do is one of the following things:\n\n1. You can try to use either hooks (post-commit, post-update I think)\n   or smudge / clean filters (via gitattributes) to do keyword\n   expansion. This hits performance, and you probably would have the\n   problems CVS ad with keyword expansion.\n\n2. You can use `export-subst` gitattribute and make git-archive do\n   keyword expansion, which can include things like '$Format:%aD$'\n   for commit date (equivalent of $Date:$?).\n\n3. You can run some local equivalent of GIT-VERSION-GEN script git\n   and Linux kernel uses, and make your build system (Makefile)\n   replace '@@VERSION@@' or '++VERSION++' keywords / placeholders\n   as part of compiling process.\n\nHTH\n-- \nJakub Narębski\nPoland\nShadeHawk on #git\n"},{"id":"95347","messageId":"8763mvlbwb.fsf@erwin.mina86.com","threadId":"16245","inReplyTo":"m3iqqvefmo.fsf@localhost.localdomain","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Michal Nazarewicz","fromEmail":"mina86@tlen.pl","sentAt":"2008-11-10T17:38:12Z","receivedAt":"2008-11-10T17:38:12Z","isPatch":false,"sender":{"key":"mina86@tlen.pl","avatar":"https://gravatar.com/avatar/55cbb4a7b7565c687a33afaee923bd3c05c46172519476bb1365631822278923?d=mp&s=160"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> The reason why git doesn't support keywords like $Revision$ or $Date$\n> is performance: the $Revision$ and $Date$ are keywords related to\n> _commit_ data, not blob data. \n\nIn my case identifying content not commit would be even better.\n\n> 1. You can try to use either hooks (post-commit, post-update I think)\n>    or smudge / clean filters (via gitattributes) to do keyword\n>    expansion. This hits performance, and you probably would have the\n>    problems CVS ad with keyword expansion.\n\nEarlier in the thread there was following code for a pre-commit hook\nmentioned:\n\n#v+\nfiles=$(git diff-index --name-only --diff-filter=AM HEAD)\nperl -pi -e 's/\\$Id.*?\\$/\\$Id: '$(TZ=UTC date +%s)' \\$/g' $files\ngit add $files\n#v-\n\nNow, this meats all my needs except that (i) it adds all the files that\nwere modified (ie. makes `git commit` work like `git commit -a`) and\n(ii) it modifies files even if the commit was aborted.\n\nSo, it seems that, what I need is: (i) a pre-commit-post-message-hook\nand (ii) a way to get a list of files that are being committed.\n\n> 2. You can use `export-subst` gitattribute and make git-archive do\n>    keyword expansion, which can include things like '$Format:%aD$'\n>    for commit date (equivalent of $Date:$?).\n>\n> 3. You can run some local equivalent of GIT-VERSION-GEN script git\n>    and Linux kernel uses, and make your build system (Makefile)\n>    replace '@@VERSION@@' or '++VERSION++' keywords / placeholders\n>    as part of compiling process.\n\nThat would work but the thing is I'd like to have visioning without the\nneed of creating releases or doing some other voodoo magic -- simply `scp\nfile remote:file` or attach to an email.\n\n-- \nBest regards,                                         _     _\n .o. | Liege of Serenly Enlightened Majesty of      o' \\,=./ `o\n ..o | Computer Science,  Michal \"mina86\" Nazarewicz   (o o)\n ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--\n"},{"id":"95349","messageId":"200811101903.27685.jnareb@gmail.com","threadId":"16245","inReplyTo":"8763mvlbwb.fsf@erwin.mina86.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-11-10T18:03:27Z","receivedAt":"2008-11-10T18:03:27Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Dnia poniedziałek 10. listopada 2008 18:38, Michal Nazarewicz napisał:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > The reason why git doesn't support keywords like $Revision$ or $Date$\n> > is performance: the $Revision$ and $Date$ are keywords related to\n> > _commit_ data, not blob data. \n> \n> In my case identifying content not commit would be even better.\n\nWell, in that case using `ident` attribute would be enough\n(but cryptic).\n\n # set `ident` attribute for all files\n $ echo '* ident' > .gitattributes\n\n # check that it is set for file 'foo'\n $ git check-attr ident -- foo\n foo: ident: set\n\n # edit file to contain '$Id$' keyword\n $ cat foo\n ...\n ... $Id$ ...\n ...\n\n # make a commit\n $ git commit -a\n\n # $Id$ keyword is replaced on checkout\n $ git add foo\n $ git checkout foo\n\n # and check that it got replaced\n $ cat foo\n ...\n ... $Id: 0ca1524d4460ba6bc91bf3adc9dab13212599243 $ ...\n ...\n\nBut you need git to make use of this SHA-1 _blob_ (contents) identifier\n\n-- \nJakub Narebski\nPoland\n"},{"id":"95368","messageId":"871vxjl5af.fsf@erwin.mina86.com","threadId":"16245","inReplyTo":"200811101903.27685.jnareb@gmail.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Michal Nazarewicz","fromEmail":"mina86@tlen.pl","sentAt":"2008-11-10T20:00:56Z","receivedAt":"2008-11-10T20:00:56Z","isPatch":false,"sender":{"key":"mina86@tlen.pl","avatar":"https://gravatar.com/avatar/55cbb4a7b7565c687a33afaee923bd3c05c46172519476bb1365631822278923?d=mp&s=160"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Dnia poniedziałek 10. listopada 2008 18:38, Michal Nazarewicz napisał:\n>> Jakub Narebski <jnareb@gmail.com> writes:\n>> \n>> > The reason why git doesn't support keywords like $Revision$ or $Date$\n>> > is performance: the $Revision$ and $Date$ are keywords related to\n>> > _commit_ data, not blob data. \n>> \n>> In my case identifying content not commit would be even better.\n>\n> Well, in that case using `ident` attribute would be enough\n> (but cryptic).\n\nYes, but it forces me to do some voodoo magic (ie. checkout) to get the\nId in the file, ;) like so:\n\n#v+\n$ echo '$Id$' >bar && git add bar && git commit -m 'Added bar' && cat bar\nCreated commit d49d436: Added bar\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 bar\n$Id$\n$ rm bar && git checkout bar && cat bar\n$Id: 055c8729cdcc372500a08db659c045e16c4409fb $\n#v-\n\nBut never mind, since it seems hard to accomplish in git, I'll have to\nlearn to live without it. ;)\n\n-- \nBest regards,                                         _     _\n .o. | Liege of Serenly Enlightened Majesty of      o' \\,=./ `o\n ..o | Computer Science,  Michal \"mina86\" Nazarewicz   (o o)\n ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--\n"},{"id":"95370","messageId":"200811102117.30372.jnareb@gmail.com","threadId":"16245","inReplyTo":"871vxjl5af.fsf@erwin.mina86.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-11-10T20:17:29Z","receivedAt":"2008-11-10T20:17:29Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Michal Nazarewicz wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n>> Dnia poniedziałek 10. listopada 2008 18:38, Michal Nazarewicz napisał:\n>>> Jakub Narebski <jnareb@gmail.com> writes:\n>>> \n>>>> The reason why git doesn't support keywords like $Revision$ or $Date$\n>>>> is performance: the $Revision$ and $Date$ are keywords related to\n>>>> _commit_ data, not blob data. \n>>> \n>>> In my case identifying content not commit would be even better.\n>>\n>> Well, in that case using `ident` attribute would be enough\n>> (but cryptic).\n> \n> Yes, but it forces me to do some voodoo magic (ie. checkout) to get the\n> Id in the file, ;) like so:\n> \n> #v+\n> $ echo '$Id$'>bar && git add bar && git commit -m 'Added bar' && cat bar\n> Created commit d49d436: Added bar\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n>  create mode 100644 bar\n> $Id$\n> $ rm bar && git checkout bar && cat bar\n> $Id: 055c8729cdcc372500a08db659c045e16c4409fb $\n> #v-\n\nWell, _some_ command has to be invoked to expand keywords. \"git add\"\ndoesn't do that (perhaps it should?), so you need to use checkout.\n\nAnd checkout doesn't touch file if it is identical, so you need\nto remove it first; nevertheless you don't need to use commit in\nbetwen, as \"git checkout bar\" would checkout file out of index (you\nadded contents of file to index with \"git add bar\").\n\n-- \nJakub Narebski\nPoland\n"},{"id":"95373","messageId":"200811102124.59973.fg@one2team.com","threadId":"16245","inReplyTo":"200811102117.30372.jnareb@gmail.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Francis Galiegue","fromEmail":"fg@one2team.com","sentAt":"2008-11-10T20:24:59Z","receivedAt":"2008-11-10T20:24:59Z","isPatch":false,"sender":{"key":"fg@one2team.com","avatar":null},"body":"Le Monday 10 November 2008 21:17:29 Jakub Narebski, vous avez écrit :\n> Michal Nazarewicz wrote:\n> > Jakub Narebski <jnareb@gmail.com> writes:\n> >> Dnia poniedziałek 10. listopada 2008 18:38, Michal Nazarewicz napisał:\n> >>> Jakub Narebski <jnareb@gmail.com> writes:\n> >>>> The reason why git doesn't support keywords like $Revision$ or $Date$\n> >>>> is performance: the $Revision$ and $Date$ are keywords related to\n> >>>> _commit_ data, not blob data.\n> >>>\n> >>> In my case identifying content not commit would be even better.\n> >>\n> >> Well, in that case using `ident` attribute would be enough\n> >> (but cryptic).\n> >\n> > Yes, but it forces me to do some voodoo magic (ie. checkout) to get the\n> > Id in the file, ;) like so:\n> >\n> > #v+\n> > $ echo '$Id$'>bar && git add bar && git commit -m 'Added bar' && cat bar\n> > Created commit d49d436: Added bar\n> >  1 files changed, 1 insertions(+), 0 deletions(-)\n> >  create mode 100644 bar\n> > $Id$\n> > $ rm bar && git checkout bar && cat bar\n> > $Id: 055c8729cdcc372500a08db659c045e16c4409fb $\n> > #v-\n>\n> Well, _some_ command has to be invoked to expand keywords. \"git add\"\n> doesn't do that (perhaps it should?), so you need to use checkout.\n>\n\nIf \"git add\" aims to do that, you'd have to be very, VERY careful, not to \nsubstitute in the wrong place to start with, not to attempt substitution in \nbinary files...\n\nAnd this would have a sizeable cost, imho. If you really want to do this, \nisn't there a hook somewhere that can do that for you, instead of modifying \ngit add directly?\n\n-- \nFrancis Galiegue\nONE2TEAM\nIngénieur système\nMob : +33 (0) 6 83 87 78 75\nTel : +33 (0) 1 78 94 55 52\nfge@one2team.com\n40 avenue Raymond Poincaré\n75116 Paris\n"},{"id":"95375","messageId":"200811102132.05472.jnareb@gmail.com","threadId":"16245","inReplyTo":"200811102124.59973.fg@one2team.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-11-10T20:32:03Z","receivedAt":"2008-11-10T20:32:03Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Dnia poniedziałek 10. listopada 2008 21:24, Francis Galiegue napisał:\n> Le Monday 10 November 2008 21:17:29 Jakub Narebski, vous avez écrit :\n\n> > Well, _some_ command has to be invoked to expand keywords. \"git add\"\n> > doesn't do that (perhaps it should?), so you need to use checkout.\n> >\n> \n> If \"git add\" aims to do that, you'd have to be very, VERY careful, not to \n> substitute in the wrong place to start with, not to attempt substitution in \n> binary files...\n> \n> And this would have a sizeable cost, imho. If you really want to do this, \n> isn't there a hook somewhere that can do that for you, instead of modifying \n> git add directly?\n\nIf I remember correctly there was idea to add 'pre-add' or 'post-add'\nhook...\n\n-- \nJakub Narebski\nPoland\n"},{"id":"95386","messageId":"866D073C-57B9-457E-80BA-0C87B6D14E23@silverinsanity.com","threadId":"16245","inReplyTo":"200811102132.05472.jnareb@gmail.com","subject":"Re: Something like $Id$, $Revision$ or $Date$?","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2008-11-10T20:58:35Z","receivedAt":"2008-11-10T20:58:35Z","isPatch":false,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"\nOn Nov 10, 2008, at 3:32 PM, Jakub Narebski wrote:\n\n> Dnia poniedziałek 10. listopada 2008 21:24, Francis Galiegue  \n> napisał:\n>> Le Monday 10 November 2008 21:17:29 Jakub Narebski, vous avez  \n>> écrit :\n>\n>>> Well, _some_ command has to be invoked to expand keywords. \"git add\"\n>>> doesn't do that (perhaps it should?), so you need to use checkout.\n>>>\n>>\n>> If \"git add\" aims to do that, you'd have to be very, VERY careful,  \n>> not to\n>> substitute in the wrong place to start with, not to attempt  \n>> substitution in\n>> binary files...\n>>\n>> And this would have a sizeable cost, imho. If you really want to do  \n>> this,\n>> isn't there a hook somewhere that can do that for you, instead of  \n>> modifying\n>> git add directly?\n>\n> If I remember correctly there was idea to add 'pre-add' or 'post-add'\n> hook...\n\nWithout adding any additional hooks, you could use the post-commit  \nhook to look for any added/changed files containing $Id$ lines and  \nforce a checkout of them.\n\nPerhaps something as simple as the following in your .git/hooks/post- \ncommit (untested, caveat emptor, YMMV):\n\ngit diff --name-only --diff-filter=AM HEAD^ HEAD | \\\nwhile read file; do\n   rm \"$file\" && git checkout -- \"$file\"\nend\n\n~~ Brian"}]}