That simplifies the code - instead of repeated checking for num_paths !=0, let's verify it once, and return if it is, and free following code from repeated ifs. Signed-off-by: Kirill Smelkov <kirr@xxxxxxxxxx> --- combine-diff.c | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/combine-diff.c b/combine-diff.c index 3e3f328..c1f481f 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1459,12 +1459,18 @@ void diff_tree_combined(const unsigned char *sha1, } } + free_pathspec(&diffopts.pathspec); + /* find out number of surviving paths */ for (num_paths = 0, p = paths; p; p = p->next) num_paths++; + /* nothing to do, if no paths */ + if (!num_paths) + return; + /* order paths according to diffcore_order */ - if (opt->orderfile && num_paths) { + if (opt->orderfile) { struct obj_order *o; o = xmalloc(sizeof(*o) * num_paths); @@ -1483,28 +1489,26 @@ void diff_tree_combined(const unsigned char *sha1, } - if (num_paths) { - if (opt->output_format & (DIFF_FORMAT_RAW | - DIFF_FORMAT_NAME | - DIFF_FORMAT_NAME_STATUS)) { - for (p = paths; p; p = p->next) - show_raw_diff(p, num_parent, rev); - needsep = 1; - } - else if (opt->output_format & - (DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT)) - needsep = 1; - else if (opt->output_format & DIFF_FORMAT_CALLBACK) - handle_combined_callback(opt, paths, num_parent, num_paths); - - if (opt->output_format & DIFF_FORMAT_PATCH) { - if (needsep) - printf("%s%c", diff_line_prefix(opt), - opt->line_termination); - for (p = paths; p; p = p->next) - show_patch_diff(p, num_parent, dense, - 0, rev); - } + if (opt->output_format & (DIFF_FORMAT_RAW | + DIFF_FORMAT_NAME | + DIFF_FORMAT_NAME_STATUS)) { + for (p = paths; p; p = p->next) + show_raw_diff(p, num_parent, rev); + needsep = 1; + } + else if (opt->output_format & + (DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT)) + needsep = 1; + else if (opt->output_format & DIFF_FORMAT_CALLBACK) + handle_combined_callback(opt, paths, num_parent, num_paths); + + if (opt->output_format & DIFF_FORMAT_PATCH) { + if (needsep) + printf("%s%c", diff_line_prefix(opt), + opt->line_termination); + for (p = paths; p; p = p->next) + show_patch_diff(p, num_parent, dense, + 0, rev); } /* Clean things up */ @@ -1513,8 +1517,6 @@ void diff_tree_combined(const unsigned char *sha1, paths = paths->next; free(tmp); } - - free_pathspec(&diffopts.pathspec); } void diff_tree_combined_merge(const struct commit *commit, int dense, -- 1.9.rc1.181.g641f458 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html