From: Johannes Sixt Date: Wed, 10 Aug 2016 19:41:56 GMT Subject: Re: [PATCH RFC] diff: add SUBMODULE_DIFF format to display submodule diff Message-ID: In-Reply-To: Am 10.08.2016 um 00:56 schrieb Jacob Keller: > On Tue, Aug 9, 2016 at 3:50 PM, Stefan Beller wrote: >> On Tue, Aug 9, 2016 at 3:32 PM, Jacob Keller wrote: >>> + if (strbuf_read(buf, cp.out, 0) < 0) >> >> So we keep the whole diff in memory >> I don't know much about the diff machinery, but I thought >> the rest of the diff machinery just streams it out? > > Yea, but I can't figure out how to do that. Is there an easy way to > stream chunks from the pipe straight into the file? You don't stream via a pipe, you let the sub-process write directly to the file: fflush(f); cp.out = dup(fileno(f)); Of course, you no longer "prepare_submodule_diff" anymore (which currently runs the child process), but you print the "Submodule" header line, then invoke the child process, and if there was a failure, you fprintf(f, "(diff failed)"). -- Hannes