{"thread":{"id":"21896","subject":"Generic filters for git archive?","startedAt":"2009-12-08T01:06:04Z","lastAt":"2009-12-15T13:06:54Z","messageCount":4,"participants":["Russ Dill","René Scharfe"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"129463","messageId":"f9d2a5e10912071706m10ed7112ob7db47cdfac510d6@mail.gmail.com","threadId":"21896","inReplyTo":null,"subject":"Generic filters for git archive?","fromName":"Russ Dill","fromEmail":"russ.dill@gmail.com","sentAt":"2009-12-08T01:06:04Z","receivedAt":"2009-12-08T01:06:04Z","isPatch":false,"sender":{"key":"russ.dill@gmail.com","avatar":"https://gravatar.com/avatar/989b24f3fa63126a35d7c74069e2626e715a3b1a86616be9962f7ceae04ff9c5?d=mp&s=160"},"body":"I'm trying to add copyright headers to my source files as they are\nexported via git archive. eg:\n\n* $Copyright$\n\nto\n\n * Copyright (c) 2003-2009 by Foo Bar\n *\n * This program is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License as published by the\n * Free Software Foundation; either version 2 of the License, or (at your\n * option) any later version.\n *\n * This program is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n * for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software Foundation,\n * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\nAnd properly handling things like '# $Copyright$', '// $Copyright$',\netc. I have a sed script that does this, but no way to apply it to the\noutput of git archive. I tried setting up a smudge filter that would\nonly smudge output on archive exports, but it doesn't appear that the\nsmudge filters get run on git archive.\n\nI am currently running 1.6.3.3\n"},{"id":"129667","messageId":"4B202945.50200@lsrfire.ath.cx","threadId":"21896","inReplyTo":"f9d2a5e10912071706m10ed7112ob7db47cdfac510d6@mail.gmail.com","subject":"Re: Generic filters for git archive?","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-12-09T22:48:37Z","receivedAt":"2009-12-09T22:48:37Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 08.12.2009 02:06, schrieb Russ Dill:\n> I'm trying to add copyright headers to my source files as they are\n> exported via git archive. eg:\n> \n> * $Copyright$\n> \n> to\n> \n>  * Copyright (c) 2003-2009 by Foo Bar\n>  *\n>  * This program is free software; you can redistribute it and/or modify it\n>  * under the terms of the GNU General Public License as published by the\n>  * Free Software Foundation; either version 2 of the License, or (at your\n>  * option) any later version.\n>  *\n>  * This program is distributed in the hope that it will be useful, but\n>  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n>  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n>  * for more details.\n>  *\n>  * You should have received a copy of the GNU General Public License\n>  * along with this program; if not, write to the Free Software Foundation,\n>  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n> \n> And properly handling things like '# $Copyright$', '// $Copyright$',\n> etc. I have a sed script that does this, but no way to apply it to the\n> output of git archive. I tried setting up a smudge filter that would\n> only smudge output on archive exports, but it doesn't appear that the\n> smudge filters get run on git archive.\n> \n> I am currently running 1.6.3.3\n\nIs the filter attribute contained in a .gitattribute file that's part of\nthe tree you are trying to export?  If it's only in the worktree copy,\nthen you need to use the option --worktree-attributes to make git\narchive use it.\n\nRené\n"},{"id":"129937","messageId":"f9d2a5e10912142308o50c8b9edy63bb485658c93a03@mail.gmail.com","threadId":"21896","inReplyTo":"4B202945.50200@lsrfire.ath.cx","subject":"Re: Generic filters for git archive?","fromName":"Russ Dill","fromEmail":"russ.dill@gmail.com","sentAt":"2009-12-15T07:08:42Z","receivedAt":"2009-12-15T07:08:42Z","isPatch":false,"sender":{"key":"russ.dill@gmail.com","avatar":"https://gravatar.com/avatar/989b24f3fa63126a35d7c74069e2626e715a3b1a86616be9962f7ceae04ff9c5?d=mp&s=160"},"body":"On Wed, Dec 9, 2009 at 3:48 PM, René Scharfe\n<rene.scharfe@lsrfire.ath.cx> wrote:\n> Am 08.12.2009 02:06, schrieb Russ Dill:\n>> I'm trying to add copyright headers to my source files as they are\n>> exported via git archive. eg:\n>>\n>> * $Copyright$\n>>\n>> to\n>>\n>>  * Copyright (c) 2003-2009 by Foo Bar\n>>  *\n>>  * This program is free software; you can redistribute it and/or modify it\n>>  * under the terms of the GNU General Public License as published by the\n>>  * Free Software Foundation; either version 2 of the License, or (at your\n>>  * option) any later version.\n>>  *\n>>  * This program is distributed in the hope that it will be useful, but\n>>  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n>>  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n>>  * for more details.\n>>  *\n>>  * You should have received a copy of the GNU General Public License\n>>  * along with this program; if not, write to the Free Software Foundation,\n>>  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n>>\n>> And properly handling things like '# $Copyright$', '// $Copyright$',\n>> etc. I have a sed script that does this, but no way to apply it to the\n>> output of git archive. I tried setting up a smudge filter that would\n>> only smudge output on archive exports, but it doesn't appear that the\n>> smudge filters get run on git archive.\n>>\n>> I am currently running 1.6.3.3\n>\n> Is the filter attribute contained in a .gitattribute file that's part of\n> the tree you are trying to export?  If it's only in the worktree copy,\n> then you need to use the option --worktree-attributes to make git\n> archive use it.\n\nhmm..It does seem to be running. But I'd really like to use the\ngitattributes from the tagged version I'm exporting and I don't want\nthe smudge filter to run on files I'm working on in my source tree,\njust on the export.\n"},{"id":"129946","messageId":"4B2789EE.1030104@lsrfire.ath.cx","threadId":"21896","inReplyTo":"f9d2a5e10912142308o50c8b9edy63bb485658c93a03@mail.gmail.com","subject":"Re: Generic filters for git archive?","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-12-15T13:06:54Z","receivedAt":"2009-12-15T13:06:54Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 15.12.2009 08:08, schrieb Russ Dill:\n> hmm..It does seem to be running. But I'd really like to use the\n> gitattributes from the tagged version I'm exporting and I don't want\n> the smudge filter to run on files I'm working on in my source tree,\n> just on the export.\n\nThis seems to work here:\n\n   $ git version\n   git version 1.6.3.3\n\n   $ mkdir /tmp/x\n   $ cd /tmp/x\n   $ git init\n   Initialized empty Git repository in /tmp/x/.git/\n\n   $ echo sc >a\n   $ git add a\n\n   $ echo '#!/bin/sh' >f\n   $ echo 'sed \"s/sc/Santa Claus/\"' >>f\n   $ chmod 755 f\n   $ git config filter.sc.smudge ./f\n\n   $ echo 'a filter=sc' >.gitattributes\n   $ git add .gitattributes\n\n   $ git commit -m.\n   [master (root-commit) 57f6bef] .\n    2 files changed, 2 insertions(+), 0 deletions(-)\n    create mode 100644 .gitattributes\n    create mode 100644 a\n\n   $ rm .gitattributes\n\n   $ git archive --prefix=x HEAD | tar xf - xa\n   $ cat xa\n   Santa Claus\n\n   $ git archive --prefix=y --worktree-attributes HEAD | tar xf - ya\n   $ cat ya\n   sc\n\nThe first archive call uses the committed .gitattributes file and runs\nthe file through the smudge filter.  The second one uses the worktree\nversion, which doesn't exist, so no filtering occurs.\n\nWhat commands do you use?\n\nThanks,\nRené\n"}]}