diff options
author | Jeff King <peff@peff.net> | 2023-08-21 22:20:46 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-08-22 00:33:24 +0200 |
commit | 5cc6b2d70bc55ab75913ee93d9ac96ad875fbb29 (patch) | |
tree | 48f2ec27489f2b98c3b555511e64db47cc168226 /builtin/diff.c | |
parent | diff: drop useless return values in git-diff helpers (diff) | |
download | git-5cc6b2d70bc55ab75913ee93d9ac96ad875fbb29.tar.xz git-5cc6b2d70bc55ab75913ee93d9ac96ad875fbb29.zip |
diff: drop useless "status" parameter from diff_result_code()
Many programs use diff_result_code() to get a user-visible program exit
code from a diff result (e.g., checking opts.found_changes if
--exit-code was requested).
This function also takes a "status" parameter, which seems at first
glance that it could be used to propagate an error encountered when
computing the diff. But it doesn't work that way:
- negative values are passed through as-is, but are not appropriate as
program exit codes
- when --exit-code or --check is in effect, we _ignore_ the passed-in
status completely. So a failed diff which did not have a chance to
set opts.found_changes would erroneously report "success, no
changes" instead of propagating the error.
After recent cleanups, neither of these bugs is possible to trigger, as
every caller just passes in "0". So rather than fixing them, we can
simply drop the useless parameter instead.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/diff.c')
-rw-r--r-- | builtin/diff.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/diff.c b/builtin/diff.c index 3eba691b82..0b313549c7 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -608,7 +608,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) builtin_diff_combined(&rev, argc, argv, ent.objects, ent.nr, first_non_parent); - result = diff_result_code(&rev.diffopt, 0); + result = diff_result_code(&rev.diffopt); if (1 < rev.diffopt.skip_stat_unmatch) refresh_index_quietly(); release_revisions(&rev); |