Commit b2b5ad5
diff: replace diff_options.dry_run flag with NULL file
We introduced a dry_run flag to diff_options in b55e6d3 (diff: ensure
consistent diff behavior with ignore options, 2025-08-08), with the idea
that the lower-level diff code could skip output when it is set.
As we saw with the bugs fixed by 3ed5d8b (diff: stop output garbled
message in dry run mode, 2025-10-20), it is easy to miss spots. In the
end, we located all of them by checking where diff_options.file is used.
That suggests another possible approach: we can replace the dry_run
boolean with a NULL pointer for "file", as we know that using "file" in
dry_run mode would always be an error. This turns any missed spots from
producing extra output[1] into a segfault. Which is less forgiving, but
that is the point: this is indicative of a programming error, and
complaining loudly and immediately is good.
[1] We protect ourselves against garbled output as a separate step,
courtesy of 623f7af (diff: restore redirection to /dev/null for
diff_from_contents, 2025-10-17). So in that sense this patch can
only introduce user-visible errors (since any "bugs" were going to
/dev/null before), but the idea is to catch them rather than quietly
send garbage to /dev/null.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 0152831 commit b2b5ad5
2 files changed
+8
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1351 | 1351 | | |
1352 | 1352 | | |
1353 | 1353 | | |
1354 | | - | |
| 1354 | + | |
1355 | 1355 | | |
1356 | 1356 | | |
1357 | 1357 | | |
| |||
3765 | 3765 | | |
3766 | 3766 | | |
3767 | 3767 | | |
3768 | | - | |
| 3768 | + | |
3769 | 3769 | | |
3770 | | - | |
| 3770 | + | |
3771 | 3771 | | |
3772 | 3772 | | |
3773 | 3773 | | |
| |||
4423 | 4423 | | |
4424 | 4424 | | |
4425 | 4425 | | |
4426 | | - | |
| 4426 | + | |
4427 | 4427 | | |
4428 | 4428 | | |
4429 | 4429 | | |
| |||
4621 | 4621 | | |
4622 | 4622 | | |
4623 | 4623 | | |
4624 | | - | |
| 4624 | + | |
4625 | 4625 | | |
4626 | 4626 | | |
4627 | 4627 | | |
| |||
6199 | 6199 | | |
6200 | 6200 | | |
6201 | 6201 | | |
6202 | | - | |
| 6202 | + | |
6203 | 6203 | | |
6204 | 6204 | | |
6205 | 6205 | | |
6206 | | - | |
| 6206 | + | |
6207 | 6207 | | |
6208 | 6208 | | |
6209 | 6209 | | |
6210 | | - | |
| 6210 | + | |
6211 | 6211 | | |
6212 | 6212 | | |
6213 | 6213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
412 | | - | |
413 | 411 | | |
414 | 412 | | |
415 | 413 | | |
| |||
0 commit comments