Re: [PATCH v3 5/5] diff: the -w option breaks --exit-code for --raw and other output modes
- From
Jeff King <peff@peff.net>
- Date
- Aug 21, 2023, 21:08 UTC
- Message-ID
- <20230821210804.GA1809621@coredump.intra.peff.net>
- In-Reply-To
- <20230821210058.GD1800481@coredump.intra.peff.net>
On Mon, Aug 21, 2023 at 05:00:58PM -0400, Jeff King wrote:
Show 21 quoted lines
> Alternatively, we could put it in the caller, like so: > > diff --git a/diff.c b/diff.c > index 78f4e7518f..e7281e75eb 100644 > --- a/diff.c > +++ b/diff.c > @@ -6528,6 +6528,7 @@ void diff_flush(struct diff_options *options) > if (check_pair_status(p)) > flush_one_pair(p, options); > } > + options->found_changes = !!q->nr; > separator++; > } > > > which matches the diffstat technique (I almost thought we could share > the code, but for the diffstat we are counting what ends up in the > diffstat struct; it does not clean out the original diff_queue when it > sees a noop pair). > > I don't see a real reason to prefer one over the other.
Actually, on second look these are not quite the same. Yours only triggers if check_pair_status() is true. So something like --diff-filter should affect both output and exit code. Yours gets that right, and mine does not. Sorry for the noise. :)
-Peff