diff options
author | Jeff King <peff@peff.net> | 2022-07-12 09:03:45 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-07-12 16:17:28 +0200 |
commit | 04393ae7f7951ba8af982cd1943c4dfb3102f6ed (patch) | |
tree | bb2bf8e3bae08577293d26dbd9d7ad65b4972914 /builtin | |
parent | revisions API: add a TODO for diff_free(&revs->diffopt) (diff) | |
download | git-04393ae7f7951ba8af982cd1943c4dfb3102f6ed.tar.xz git-04393ae7f7951ba8af982cd1943c4dfb3102f6ed.zip |
diff-files: move misplaced cleanup label
Commit 0139c58ab9 (revisions API users: add "goto cleanup" for
release_revisions(), 2022-04-13) converted an early return in
cmd_diff_files() into a goto. But it put the cleanup label too early: if
read_cache_preload() returns an error, we'll set result to "-1", but
then jump to calling run_diff_files(), overwriting our result.
We should jump past the call to run_diff_files(). Likewise, we should go
past diff_result_code(), which is expecting to see a code from an actual
diff, not a negative error code.
In practice, I suspect this bug cannot actually be triggered, because
read_cache_preload() does not seem to ever return an error. Its return
value (eventually) comes from do_read_index(), which gives the number of
cache entries found, and calls die() on error. Still, it makes sense to
fix the inadvertent change from 0139c58ab9 first, and we can look into
the overall error handling of read_cache() separately (which is present
in many other callsites).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/diff-files.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/diff-files.c b/builtin/diff-files.c index 2bfaf9ba7a..92cf6e1e92 100644 --- a/builtin/diff-files.c +++ b/builtin/diff-files.c @@ -80,9 +80,9 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) result = -1; goto cleanup; } -cleanup: result = run_diff_files(&rev, options); result = diff_result_code(&rev.diffopt, result); +cleanup: release_revisions(&rev); return result; } |