{"thread":{"id":"13020","subject":"auto insert history info into source files, at commit?","startedAt":"2008-04-08T16:03:02Z","lastAt":"2008-04-08T19:00:49Z","messageCount":3,"participants":["oxcrete","Jakub Narebski","Santi Béjar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"73853","messageId":"16562665.post@talk.nabble.com","threadId":"13020","inReplyTo":null,"subject":"auto insert history info into source files, at commit?","fromName":"oxcrete","fromEmail":"oxcrete@yahoo.com","sentAt":"2008-04-08T16:03:02Z","receivedAt":"2008-04-08T16:03:02Z","isPatch":false,"sender":{"key":"oxcrete@yahoo.com","avatar":null},"body":"\nHow do you do this with Git? I couldn't find it in the documentation.  the\nstandard $Log, $revision... didn't seem to work. I'll take an RTFM answer if\nyou can point me to the right section in the manual. Appologies, if this was\nposted before - couldn't find a good regex to search this topic.\n-- \nView this message in context: http://www.nabble.com/auto-insert-history-info-into-source-files%2C-at-commit--tp16562665p16562665.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"73857","messageId":"m38wzoth0l.fsf@localhost.localdomain","threadId":"13020","inReplyTo":"16562665.post@talk.nabble.com","subject":"Re: auto insert history info into source files, at commit?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-04-08T17:04:43Z","receivedAt":"2008-04-08T17:04:43Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"oxcrete <oxcrete@yahoo.com> writes:\n\n> How do you do this with Git? I couldn't find it in the documentation.  the\n> standard $Log, $Revision... didn't seem to work. I'll take an RTFM answer if\n> you can point me to the right section in the manual. Appologies, if this was\n> posted before - couldn't find a good regex to search this topic.\n\nhttp://git.or.cz/gitwiki/GitFaq#head-4a0afe71a2bb7734777a8b0b345e0308aefdbd40\n\"Does git have keyword expansion?\" (and also next section, \"Does git\nallow arbitrary conversion of contents?\")\n\nSimply said keywords do not work well together with nonlinear history,\nand especially with the way git is engineered, being content-adressed.\nIf you have the following history:\n\n  A---B---C---D---E\n           \\\n            \\-F---G---H\n\nand the file 'foo' has the same contents in both branches, in both E\nand H commits (revisions), it would be noticed by git and it wouldn't\ntouch this file when switching branches.  It is one of the keys to git\nperformance.  This is important not only for switching branches, but\nalso for merging.\n\nBut if they have $Revision$, or $Author$ keywords, and those would be\ndifferent, it couldn't be done this way.\n\n\nTherefore git supports \"keyword expansion\" in three ways, beginning\nfrom simplest.\n\n1. The `ident` attribute, which allows to expand $Id$ to \n$Id: <sha-1>$, where <sha-1> is blob (file contents) identifier.\n\n2. The `export-subst` attribute, and/or various tricks in Makefile,\nwhich allow embedding information about current revision (like result\nof \"git describe\") in files when using \"git archive\" (atribute), or\n\"make\" / \"make dist\".  This is I think the preferred way; both git and\nLinux use Makefile tricks to embed version info in result of\ncompilation.\n\n3. Use `filter` attribute to expand keywords when checking out file,\nand removing keywords when commiting changes (but watch for binary\nfiles!).  This would affect performance.  I also don't think that\nthere is any example doing keyword expansion with `filter`\ngitattribute; you can be first! ;-)\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"73865","messageId":"8aa486160804081200s163a40bcmf3f2282e0ba00dd6@mail.gmail.com","threadId":"13020","inReplyTo":"16562665.post@talk.nabble.com","subject":"Re: auto insert history info into source files, at commit?","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-04-08T19:00:49Z","receivedAt":"2008-04-08T19:00:49Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Tue, Apr 8, 2008 at 6:03 PM, oxcrete <oxcrete@yahoo.com> wrote:\n>\n>  How do you do this with Git? I couldn't find it in the documentation.  the\n>  standard $Log, $revision... didn't seem to work. I'll take an RTFM answer if\n>  you can point me to the right section in the manual. Appologies, if this was\n>  posted before - couldn't find a good regex to search this topic.\n\nhttp://git.or.cz/gitwiki/GitFaq#head-4a0afe71a2bb7734777a8b0b345e0308aefdbd40\n\nSanti\n"}]}