Re: [PATCH RFC] diff: add SUBMODULE_DIFF format to display submodule diff
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Aug 10, 2016, 19:41 UTC
- Message-ID
- <b44c853f-2b4b-0eeb-ba1a-df0e650f7868@kdbg.org>
- In-Reply-To
- <CA+P7+xqnALzwkgLXrP57BUtFGaxGudAEG7cmGTakP47ofFEjHQ@mail.gmail.com>
Am 10.08.2016 um 00:56 schrieb Jacob Keller:
Show 10 quoted lines
> On Tue, Aug 9, 2016 at 3:50 PM, Stefan Beller <sbeller@google.com> wrote: >> On Tue, Aug 9, 2016 at 3:32 PM, Jacob Keller <jacob.e.keller@intel.com> 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