git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Looking for help to understand external filter driver code

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 19, 2016, 17:56 UTC
Message-ID
<xmqqbn1th5qn.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<67D9AC88-550E-4549-9AFD-2401B70B363B@gmail.com>
Lars Schneider <larsxschneider@gmail.com> writes:
Show 5 quoted lines
> a long time ago in aa4ed4 Junio introduced the external filter
> driver definition. Since that time we fork the Git process and
> then we fork again to run the external filter. This is probably a
> super stupid question with an obvious answer... but can anyone
> help me to understand the code and explain why we fork twice?
In "git show aa4ed4" you find this picture:
       /*
        * Create a pipeline to have the command filter the buffer's
        * contents.
        *
        * (child --> cmd) --> us
        */

where "child" is a fork of the original Git process; it still has the <src, size> buffered data inherited from the original process, so it can write_in_full() into the pipe going to the cmd process. "us" is the original process that has the reading end of the pipe that connects us to the "(child --> cmd)" processes, so that it can read the filtered result from them.

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.

Previous: Lars SchneiderNext: Junio C Hamano
Message 2 of 10 in “Looking for help to understand external filter driver code”
  1. Lars SchneiderJul 19, 2016
  2. Junio C HamanoJul 19, 2016
  3. Junio C HamanoJul 19, 2016
  4. Lars SchneiderJul 19, 2016
  5. Junio C HamanoJul 19, 2016
  6. Lars SchneiderJul 19, 2016
  7. Torsten BögershausenJul 20, 2016
  8. Jakub NarębskiJul 20, 2016
  9. Lars SchneiderJul 20, 2016
  10. Jeff KingJul 20, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.