Re: [PATCH v3 1/5] diff: move the fallback "--exit-code" code down
- From
Jeff King <peff@peff.net>
- Date
- Aug 21, 2023, 20:41 UTC
- Message-ID
- <20230821204106.GB1800481@coredump.intra.peff.net>
- In-Reply-To
- <20230818235932.3253552-2-gitster@pobox.com>
On Fri, Aug 18, 2023 at 04:59:28PM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> diff --git a/diff.c b/diff.c
> index d52db685f7..0ce678fc06 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -6551,6 +6551,21 @@ void diff_flush(struct diff_options *options)
> separator++;
> }
>
> + if (output_format & DIFF_FORMAT_PATCH) {
> + if (separator) {This step makes sense, but I did a double-take when looking at the patch, because it is moving code _up_ rather than _down_. But the problem is that the block you moved was larger than the intervening bit, so the diff chose to flip-flop the context and changed bits.
Obviously orthogonal to your series, but I wonder if there's a way to convince Git to show what actually happened. I don't think this is really a heuristic or algorithm problem. Seeing the pre- and post-images, it can't know whether it was "move A up" or "move B down", and the "real" diff is simply much larger in this case.
-Peff