{"thread":{"id":"33006","subject":"[PATCH] diff-lib: drop return value from do_diff_cache()","startedAt":"2013-02-25T14:00:45Z","lastAt":"2013-02-25T14:00:45Z","messageCount":1,"participants":["Nguyễn Thái Ngọc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"210246","messageId":"1361800845-21958-1-git-send-email-pclouds@gmail.com","threadId":"33006","inReplyTo":null,"subject":"[PATCH] diff-lib: drop return value from do_diff_cache()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2013-02-25T14:00:45Z","receivedAt":"2013-02-25T14:00:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Since 204ce97 (Also use unpack_trees() in do_diff_cache() -\n2008-01-20), do_diff_cache() always returns zero. It does not make\nsense to check its return value any more.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n I don't know the history behind this function. But it feels not right\n to do exit(128) in do_diff_cache (since 203a2fe (Allow callers of\n unpack_trees() to handle failure - 2008-02-07) and limit the caller's\n control here.\n\n builtin/reset.c | 3 +--\n diff-lib.c      | 3 +--\n diff.h          | 2 +-\n 3 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 6032131..843d337 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -140,8 +140,7 @@ static int read_from_tree(const char **pathspec, unsigned char *tree_sha1)\n \topt.format_callback = update_index_from_diff;\n \n \tread_cache();\n-\tif (do_diff_cache(tree_sha1, &opt))\n-\t\treturn 1;\n+\tdo_diff_cache(tree_sha1, &opt);\n \tdiffcore_std(&opt);\n \tdiff_flush(&opt);\n \tdiff_tree_release_paths(&opt);\ndiff --git a/diff-lib.c b/diff-lib.c\nindex f35de0f..5a5fc94 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -495,7 +495,7 @@ int run_diff_index(struct rev_info *revs, int cached)\n \treturn 0;\n }\n \n-int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)\n+void do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)\n {\n \tstruct rev_info revs;\n \n@@ -505,7 +505,6 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)\n \n \tif (diff_cache(&revs, tree_sha1, NULL, 1))\n \t\texit(128);\n-\treturn 0;\n }\n \n int index_differs_from(const char *def, int diff_flags)\ndiff --git a/diff.h b/diff.h\nindex 78b4091..aaa9a4e 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -319,7 +319,7 @@ extern const char *diff_unique_abbrev(const unsigned char *, int);\n extern int run_diff_files(struct rev_info *revs, unsigned int option);\n extern int run_diff_index(struct rev_info *revs, int cached);\n \n-extern int do_diff_cache(const unsigned char *, struct diff_options *);\n+extern void do_diff_cache(const unsigned char *, struct diff_options *);\n extern int diff_flush_patch_id(struct diff_options *, unsigned char *);\n \n extern int diff_result_code(struct diff_options *, int);\n-- \n1.8.1.2.536.gf441e6d\n"}]}