Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2023-08-21 23:15:10 +0300
committerJunio C Hamano <gitster@pobox.com>2023-08-22 01:33:24 +0300
commitf126f6ec221ec9f8aac3f1aebf855bbc46e9b796 (patch)
tree48ebd28097b5d4c1196703e837f8e5764617e708 /builtin/diff-files.c
parent976b97e3fd95d5daa38ed453349f5a92157a1db2 (diff)
diff-files: avoid negative exit value
If loading the index fails, we print an error and then return "-1" from the function. But since this is a builtin, we end up with exit(-1), which produces odd results since program exit codes are unsigned. Because of integer conversion, it usually becomes 255, which is at least still an error, but values above 128 are usually interpreted as signal death. Since we know the program is exiting immediately, we can just replace the error return with a die(). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/diff-files.c')
-rw-r--r--builtin/diff-files.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 50330b8dd2..2e3e948583 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -80,14 +80,10 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
(rev.diffopt.output_format & DIFF_FORMAT_PATCH))
diff_merges_set_dense_combined_if_unset(&rev);
- if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
- perror("repo_read_index_preload");
- result = -1;
- goto cleanup;
- }
+ if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0)
+ die_errno("repo_read_index_preload");
result = run_diff_files(&rev, options);
result = diff_result_code(&rev.diffopt, result);
-cleanup:
release_revisions(&rev);
return result;
}