Subject: Re: [PATCH 2/4] add smudge-to-file and clean-from-file filter configuration

From: Junio C Hamano <[email-masked]>
Date: Fri, 17 Jun 2016 09:09:45 -0700

Joey Hess <[email-masked]> writes:

>> Do you make any promises that %p is a seekable file?
>
> Yes, %p is a regular file and so is seekable, statable, etc.

I wonder if we prefer not to make this customizable (i.e. not having
to use'%p').  Unlike '%f' that is optional, smudgeTo and cleanFrom
"filters" are not filters and MUST read from the path given and not
from any other paths.

A misconfigured smudgeTo filter that uses %f would overwrite a wrong
file when used with checkout-index --prefix=<there>, right?

The only thing '%p' buys is that a "filter" could be written in such
a way that takes the pathname at arbitrary place on the command
line.  A command line that does not have '%p' anywhere is invalid,
which is quite different from how '%f' behaves.

Would an interface that always appends the pathname at the end of
the command line string work?  E.g.

	[filter "foo"] smugeToFile = cmd --from-file

would run "cmd --from-file PATH" when Git wants it to read from
PATH, and

	[filter "bar"] smugeToFile = sh -c 'cmd --from-file="$0"'

would run

	sh -c 'cmd --from-file="$0"' PATH

which in turn becomes 'cmd --from-file=PATH'.

Or something like that.