{"thread":{"id":"10851","subject":"Integrating with hooks","startedAt":"2007-11-13T17:37:21Z","lastAt":"2007-11-15T07:57:42Z","messageCount":6,"participants":["Todd A. Jacobs","Jakub Narebski","Johannes Schindelin","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"59726","messageId":"20071113173721.GI25282@penguin.codegnome.org","threadId":"10851","inReplyTo":null,"subject":"Integrating with hooks","fromName":"Todd A. Jacobs","fromEmail":"nospam@codegnome.org","sentAt":"2007-11-13T17:37:21Z","receivedAt":"2007-11-13T17:37:21Z","isPatch":false,"sender":{"key":"nospam@codegnome.org","avatar":null},"body":"I've created some bash functions which handle tagging some files with\nrevision information, but even after reading the git manual I'm not\nreally sure how to integrate them so that they remove revision expansion\nbefore each check-in (to avoid cluttering the repository with keyword\nsubstitutions), and add them back (with the current commit info) after\neach commit.\n\nThese are the functions:\n\n    # Show some kind of useful revision string, like the RCS $Id$ string. I\n    # think commit hash, filename, hostname containing the repository, and\n    # timestamp should be plenty of information to track down a given file.\n    git-id () {\n\tfor file in \"$@\"; do\n\t    _date=$(date +'%F %T %Z')\n\t    git log -1 \\\n\t\t--pretty=format:\"[%h] \\\"$file\\\" $(hostname -f) ($_date)\" \\\n\t\t\"$file\"\n\tdone\n    }\n    # Replace the $Id$ keyword string in the file itself.\n    git-export () {\n\tfor file in \"$@\"; do\n\t    echo Modifying $file...\n\t    _id=$(git-id \"$file\")\n\t    sed -ri 's/\\$(Id|Revision).*\\$/$Id: '\"$_id\"' $/' \"$file\"\n\tdone\n    }\n    # Clean the $Id$ keyword string to prevent cluttering the repository\n    # with keyword-revision diffs when we check the file back in.\n    git-unexport () {\n\tfor file in \"$@\"; do\n\t    echo Resetting $file...\n\t    sed -ri 's/\\$Id.*\\$/$Id$/' \"$file\"\n\tdone\n    }\n\nHow do I hook this in the way I want so that it's handled automatically?\n\n-- \n\"Oh, look: rocks!\"\n\t-- Doctor Who, \"Destiny of the Daleks\"\n"},{"id":"59768","messageId":"fhdane$kfs$1@ger.gmane.org","threadId":"10851","inReplyTo":"20071113173721.GI25282@penguin.codegnome.org","subject":"Re: Integrating with hooks","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-13T23:07:29Z","receivedAt":"2007-11-13T23:07:29Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"[Cc: Todd A. Jacobs <nospam@codegnome.org>, git@vger.kernel.org]\n\nTodd A. Jacobs wrote:\n\n> I've created some bash functions which handle tagging some files with\n> revision information, but even after reading the git manual I'm not\n> really sure how to integrate them so that they remove revision expansion\n> before each check-in (to avoid cluttering the repository with keyword\n> substitutions), and add them back (with the current commit info) after\n> each commit.\n> \n> These are the functions:\n\n[...]\n\n> How do I hook this in the way I want so that it's handled automatically?\n\nTake a look at gitattributes(5), namely 'filter' attribute.\n\nAlthough instead of implementing it \"by hand\", perhaps it would be\nenough to use 'ident' and/or 'export-subs' attribute.\n\nP.S. Because of the way git updates files, and git thinks about files\nit is I think universally regarded to be bad idea to put in a file\nany Id that depend on commit data.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"59901","messageId":"20071115011837.GD32746@penguin.codegnome.org","threadId":"10851","inReplyTo":"fhdane$kfs$1@ger.gmane.org","subject":"Re: Integrating with hooks","fromName":"Todd A. Jacobs","fromEmail":"nospam@codegnome.org","sentAt":"2007-11-15T01:18:37Z","receivedAt":"2007-11-15T01:18:37Z","isPatch":false,"sender":{"key":"nospam@codegnome.org","avatar":null},"body":"On Wed, Nov 14, 2007 at 12:07:29AM +0100, Jakub Narebski wrote:\n\n> Take a look at gitattributes(5), namely 'filter' attribute.\n\nThanks, I took a look at the man page you suggested. The \"ident\" feature\nalmost does what I want, but doesn't seem to take any sort of format\nstring. So, I thought I'd explore \"filter,\" but can't really find any\nexamples of how to implement the smudge and clean commands, which seem\nto be what I'm really trying to do here.\n\nIs there an example somewhere that you can point me to? The man page\ndoesn't really show any examples of how to implement the filter\nattribute, so I'm a little unsure how to proceed.\n\n-- \n\"Oh, look: rocks!\"\n\t-- Doctor Who, \"Destiny of the Daleks\"\n"},{"id":"59904","messageId":"fhg87q$k21$1@ger.gmane.org","threadId":"10851","inReplyTo":"20071115011837.GD32746@penguin.codegnome.org","subject":"Re: Integrating with hooks","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-15T01:43:22Z","receivedAt":"2007-11-15T01:43:22Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Todd A. Jacobs wrote:\n\n> On Wed, Nov 14, 2007 at 12:07:29AM +0100, Jakub Narebski wrote:\n> \n>> Take a look at gitattributes(5), namely 'filter' attribute.\n> \n> Thanks, I took a look at the man page you suggested. The \"ident\" feature\n> almost does what I want, but doesn't seem to take any sort of format\n> string. \n\nThe `ident` feature provides only sensible Id for a file (if you want to\navoid potentially rewriting _all_ and not only changed files on checkout /\nswitching branch / reset --hard). All Ids which have commit info, like\ncommit id, commit date, author are not sensible in mentioned sense.\n\n> So, I thought I'd explore \"filter,\" but can't really find any \n> examples of how to implement the smudge and clean commands, which seem\n> to be what I'm really trying to do here.\n> \n> Is there an example somewhere that you can point me to? The man page\n> doesn't really show any examples of how to implement the filter\n> attribute, so I'm a little unsure how to proceed.\n\nCannot help you there, but see examples of `diff` and `merge` attributes,\nit should I think be similar.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"59905","messageId":"Pine.LNX.4.64.0711150143420.4362@racer.site","threadId":"10851","inReplyTo":"20071115011837.GD32746@penguin.codegnome.org","subject":"Re: Integrating with hooks","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-15T01:43:59Z","receivedAt":"2007-11-15T01:43:59Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Nov 2007, Todd A. Jacobs wrote:\n\n> On Wed, Nov 14, 2007 at 12:07:29AM +0100, Jakub Narebski wrote:\n> \n> > Take a look at gitattributes(5), namely 'filter' attribute.\n> \n> Thanks, I took a look at the man page you suggested. The \"ident\" feature \n> almost does what I want, but doesn't seem to take any sort of format \n> string.\n\nNote that the ident feature will give you _only_ the blob sha1.  \n\nI guess that you're more interested in the export-subst feature.\n\nHth,\nDscho\n"},{"id":"59942","messageId":"473BFBF6.7070902@viscovery.net","threadId":"10851","inReplyTo":"20071115011837.GD32746@penguin.codegnome.org","subject":"Re: Integrating with hooks","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-11-15T07:57:42Z","receivedAt":"2007-11-15T07:57:42Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Todd A. Jacobs schrieb:\n> On Wed, Nov 14, 2007 at 12:07:29AM +0100, Jakub Narebski wrote:\n> \n>> Take a look at gitattributes(5), namely 'filter' attribute.\n> \n> Thanks, I took a look at the man page you suggested. The \"ident\" feature\n> almost does what I want, but doesn't seem to take any sort of format\n> string. So, I thought I'd explore \"filter,\" but can't really find any\n> examples of how to implement the smudge and clean commands, which seem\n> to be what I'm really trying to do here.\n\nA clean and smudge filter processes one file at a time. It reads the old \ncontent from stdin and writes the result to stdout.\n\nThere is a tiny example in the test suite, t/t0021-conversion.sh, look for \nrot13.sh.\n\n-- Hannes\n"}]}