]> git.ipfire.org Git - thirdparty/git.git/commit
diff: simplify run_external_diff() quiet logic
authorJeff King <peff@peff.net>
Fri, 24 Oct 2025 17:25:07 +0000 (13:25 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Oct 2025 17:38:58 +0000 (10:38 -0700)
commit2ecb8857e7785b6b27887164cb1aca67ce0b114a
tree7b313f83b83e990eb1dceb088a945a49c702c072
parent1ad2760020bf426edd01ccec467da14c0f92cf2e
diff: simplify run_external_diff() quiet logic

We'd sometimes end up in run_external_diff() to do a dry-run diff (e.g.,
to find content-level changes for --quiet). We recognize this quiet mode
by seeing the lack of DIFF_FORMAT_PATCH in the output format.

But since introducing an explicit dry-run check via 3ed5d8bd73 (diff:
stop output garbled message in dry run mode, 2025-10-20), this logic can
never trigger. We can only get to this function by calling
diff_flush_patch(), and that comes from only two places:

  1. A dry-run flush comes from diff_flush_patch_quietly(), which is
     always in dry-run mode (so the other half of our "||" is true
     anyway).

  2. A regular flush comes from diff_flush_patch_all_file_pairs(),
     which is only called when output_format has DIFF_FORMAT_PATCH in
     it.

So we can simplify our "quiet" condition to just checking dry-run mode
(which used to be a specific flag, but recently became just a NULL
"file" pointer). And since it's so simple, we can just do that inline.
This makes the logic about o->file more obvious, since we handle the
NULL and non-stdout cases next to each other.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c