Re: [PATCH 2/4] add smudge-to-file and clean-from-file filter configuration
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 17, 2016, 16:09 UTC
- Message-ID
- <xmqq60t73igm.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160617124707.GB24025@kitenet.net>
Joey Hess <id@joeyh.name> 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.