diff options
author | Jeff King <peff@peff.net> | 2023-08-21 22:17:27 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-08-22 00:33:24 +0200 |
commit | 3755077b506356017d942dbcc2ffe9cb17ecc606 (patch) | |
tree | ee0484d3c134da144806e98f1919d8f7b01f78d6 /wt-status.c | |
parent | diff: show usage for unknown builtin_diff_files() options (diff) | |
download | git-3755077b506356017d942dbcc2ffe9cb17ecc606.tar.xz git-3755077b506356017d942dbcc2ffe9cb17ecc606.zip |
diff: die when failing to read index in git-diff builtin
When the git-diff program fails to read the index in its diff-files or
diff-index helper functions, it propagates the error up the stack. This
eventually lands in diff_result_code(), which does not handle it well
(as discussed in the previous patch).
Since the only sensible thing here is to exit with an error code (and
what we were expecting the propagated error code to cause), let's just
do that directly.
There's no test here, as I'm not even sure this case can be triggered.
The index-reading functions tend to die() themselves when encountering
any errors, and the return value is just the number of entries in the
file (and so always 0 or positive). But let's err on the conservative
side and keep checking the return value. It may be worth digging into as
a separate topic (though index-reading is low-level enough that we
probably want to eventually teach it to propagate errors anyway for
lib-ification purposes, at which point this code would already be doing
the right thing).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
0 files changed, 0 insertions, 0 deletions