Subject: Re: Generic filters for git archive?

From: René Scharfe <[email-masked]>
Date: Tue, 15 Dec 2009 14:06:54 +0100

Am 15.12.2009 08:08, schrieb Russ Dill:
> hmm..It does seem to be running. But I'd really like to use the
> gitattributes from the tagged version I'm exporting and I don't want
> the smudge filter to run on files I'm working on in my source tree,
> just on the export.

This seems to work here:

   $ git version
   git version 1.6.3.3

   $ mkdir /tmp/x
   $ cd /tmp/x
   $ git init
   Initialized empty Git repository in /tmp/x/.git/

   $ echo sc >a
   $ git add a

   $ echo '#!/bin/sh' >f
   $ echo 'sed "s/sc/Santa Claus/"' >>f
   $ chmod 755 f
   $ git config filter.sc.smudge ./f

   $ echo 'a filter=sc' >.gitattributes
   $ git add .gitattributes

   $ git commit -m.
   [master (root-commit) 57f6bef] .
    2 files changed, 2 insertions(+), 0 deletions(-)
    create mode 100644 .gitattributes
    create mode 100644 a

   $ rm .gitattributes

   $ git archive --prefix=x HEAD | tar xf - xa
   $ cat xa
   Santa Claus

   $ git archive --prefix=y --worktree-attributes HEAD | tar xf - ya
   $ cat ya
   sc

The first archive call uses the committed .gitattributes file and runs
the file through the smudge filter.  The second one uses the worktree
version, which doesn't exist, so no filtering occurs.

What commands do you use?

Thanks,
René