Re: Looking for help to understand external filter driver code
- From
Lars Schneider <larsxschneider@gmail.com>
- Date
- Jul 19, 2016, 20:44 UTC
- Message-ID
- <7B44C694-7CB2-411D-9CC6-7334CCBAD20B@gmail.com>
- In-Reply-To
- <xmqqlh0xfoho.fsf@gitster.mtv.corp.google.com>
On 19 Jul 2016, at 20:53, Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> Junio C Hamano <gitster@pobox.com> writes: > >> The key benefit of this arrangement is the above can be done without >> having to do poll() to flip between reading and writing that is >> needed to avoid deadlocking, which kept the code simpler. A later >> conversion of the write side into async does not fundamentally >> change anything from the original arrangement. > > Translation: I was too lazy to worry about doing poll()/select() > when I did it originally. As long as you can do so correctly, be my > guest to reduce one process by having the main process do both > reading and writing. > > ;-)
Thanks a lot for this explanation. My goal is to add an option to the clean/smudge filter config that instructs Git to keep the external filter process running. Whenever Git encounters a file to be filtered then it would continue to talk to the filter process over a simple pipe protocol:
Git writes --> 4 byte filename length Git writes --> filename string Git writes --> 4 byte content length Git writes --> content string Git reads <-- 4 byte filtered content length Git reads <-- filtered content
I still need to read more about poll()/select() but it looks to me as if these functions are only required if Git doesn't know what to expect. With the sketched protocol above that wouldn't be the case. Therefore, I wonder if I would need to use poll()/select()?
Thanks, Lars