[PATCH] diff-lib: drop return value from do_diff_cache()
From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:56:15
Subsystem:
the rest · Maintainer:
Linus Torvalds
Since 204ce97 (Also use unpack_trees() in do_diff_cache() - 2008-01-20), do_diff_cache() always returns zero. It does not make sense to check its return value any more. Signed-off-by: Nguyễn Thái Ngọc Duy <redacted> --- I don't know the history behind this function. But it feels not right to do exit(128) in do_diff_cache (since 203a2fe (Allow callers of unpack_trees() to handle failure - 2008-02-07) and limit the caller's control here. builtin/reset.c | 3 +-- diff-lib.c | 3 +-- diff.h | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..843d337 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c@@ -140,8 +140,7 @@ static int read_from_tree(const char **pathspec, unsigned char *tree_sha1) opt.format_callback = update_index_from_diff; read_cache(); - if (do_diff_cache(tree_sha1, &opt)) - return 1; + do_diff_cache(tree_sha1, &opt); diffcore_std(&opt); diff_flush(&opt); diff_tree_release_paths(&opt);
diff --git a/diff-lib.c b/diff-lib.c
index f35de0f..5a5fc94 100644
--- a/diff-lib.c
+++ b/diff-lib.c@@ -495,7 +495,7 @@ int run_diff_index(struct rev_info *revs, int cached) return 0; } -int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt) +void do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt) { struct rev_info revs;
@@ -505,7 +505,6 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt) if (diff_cache(&revs, tree_sha1, NULL, 1)) exit(128); - return 0; } int index_differs_from(const char *def, int diff_flags)
diff --git a/diff.h b/diff.h
index 78b4091..aaa9a4e 100644
--- a/diff.h
+++ b/diff.h@@ -319,7 +319,7 @@ extern const char *diff_unique_abbrev(const unsigned char *, int); extern int run_diff_files(struct rev_info *revs, unsigned int option); extern int run_diff_index(struct rev_info *revs, int cached); -extern int do_diff_cache(const unsigned char *, struct diff_options *); +extern void do_diff_cache(const unsigned char *, struct diff_options *); extern int diff_flush_patch_id(struct diff_options *, unsigned char *); extern int diff_result_code(struct diff_options *, int);
--
1.8.1.2.536.gf441e6d