Subject: Re: [PATCH v2] diff: ensure consistent diff behavior with -I<regex> across output formats

From: Junio C Hamano <[email-masked]>
Date: Tue, 05 Aug 2025 09:11:25 -0700

Lidong Yan <[email-masked]> writes:

> I’m proposing to add a .diff_optimize field to struct diff_options, which
> would support three modes: DIFF_OPT_NONE, DIFF_OPT_DRY_RUN,
> and DIFF_OPT_BUFFER. The appropriate value would be determined
> before calling diff_flush(), potentially in repo_diff_setup().
> ...
> However, I’m concerned that DIFF_OPT_BUFFER could lead to high memory
> usage in Git, and I’m not entirely sure if this trade-off is justified.

The DRY_RUN mode would make very good sense, and I agree with you
that it is better to leave the BUFFER mode out.  It is hard to do
right (like, keeping up to certain small amount of diff in memory
and then spill it to an external temporary file if we are getting
too much), and the value to have it is questionable, especially in
the initial attempt.

Thanks.