Re: Designing the filter process protocol (was: Re: [PATCH v3 10/10] convert: add filter.<driver>.process option)
- From
Lars Schneider <larsxschneider@gmail.com>
- Date
- Aug 6, 2016, 18:24 UTC
- Message-ID
- <90A43E20-B2F5-4377-8DC3-2298BDD7CC71@gmail.com>
- In-Reply-To
- <607c07fe-5b6f-fd67-13e1-705020c267ee@gmail.com>
Show 26 quoted lines
> On 03 Aug 2016, at 20:30, Jakub Narębski <jnareb@gmail.com> wrote: > > ... > > > 2. HANDSHAKE (INITIALIZATION) > > Next, there is deciding on and designing the handshake between Git (between > Git command) and the filter driver process. With the `filter.<driver>.process` > solution the driver needs to tell which operations among (for now) "clean" > and "smudge" it does support. Plus it provides a way to extend protocol, > adding new features, like support for streaming, cleaning from file or > smudging to file, providing size upfront, perhaps even progress report. > > Current handshake consist of filter driver printing a signature, version > number and capabilities, in that order. Git checks that it is well formed > and matches expectations, and notes which of "clean" and "smudge" operations > are supported by the filter. > > There is no interaction from the Git side in the handshake, for example to > set options and expectations common to all files being filtered. Take > one possible extension of protocol: supporting streaming. The filter > driver needs to know whether it needs to read all the input, or whether > it can start printing output while input is incoming (e.g. to reduce > memory consumption)... though we may simply decide it to be next version > of the protocol.
I would like to change the startup sequence to this:
Git starts the filter when it encounters the first file that needs to be cleaned or smudged. After the filter started Git sends a welcome message, a list of supported protocol version numbers, and a flush packet. Git expects to read the welcome message and one protocol version number from the previously sent list. Afterwards Git sends a list of supported capabilities and a flush packet. Git expects to read a list of desired capabilities, which must be a subset of the supported capabilities list, and a flush packet as response: ------------------------ packet: git> git-filter-client packet: git> version=2 packet: git> version=42 packet: git> 0000 packet: git< git-filter-server packet: git< version=2 packet: git> clean=true packet: git> smudge=true packet: git> not-yet-invented=true packet: git> 0000 packet: git< clean=true packet: git< smudge=true packet: git< 0000 ------------------------
This would allow us to detect the case if a user configures an existing clean/smudge filter as `filter.<driver>.process`. Since Git is talking first, it would not "hang" in that case.
Would that be ok with you?
Thanks, Lars