Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/grep.c | 39 +++++++++++++++++---------------------- 1 files changed, 17 insertions(+), 22 deletions(-) diff --git a/builtin/grep.c b/builtin/grep.c index 40b9a93..b8a1d5c 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -568,7 +568,6 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached) if (hit && opt->status_only) break; } - free_grep_patterns(opt); return hit; } @@ -969,7 +968,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) } if (!use_index) { - int hit; if (cached) die("--cached cannot be used with --no-index."); if (list.nr) @@ -977,35 +975,32 @@ int cmd_grep(int argc, const char **argv, const char *prefix) hit = grep_directory(&opt, paths); if (use_threads) hit |= wait_all(); - return !hit; } - - if (!list.nr) { - int hit; + else if (!list.nr) { if (!cached) setup_work_tree(); - hit = grep_cache(&opt, paths, cached); if (use_threads) hit |= wait_all(); - return !hit; + free_grep_patterns(&opt); } - - if (cached) - die("both --cached and trees are given."); - - for (i = 0; i < list.nr; i++) { - struct object *real_obj; - real_obj = deref_tag(list.objects[i].item, NULL, 0); - if (grep_object(&opt, paths, real_obj, list.objects[i].name)) { - hit = 1; - if (opt.status_only) - break; + else { + if (cached) + die("both --cached and trees are given."); + + for (i = 0; i < list.nr; i++) { + struct object *real_obj; + real_obj = deref_tag(list.objects[i].item, NULL, 0); + if (grep_object(&opt, paths, real_obj, list.objects[i].name)) { + hit = 1; + if (opt.status_only) + break; + } } + if (use_threads) + hit |= wait_all(); + free_grep_patterns(&opt); } - if (use_threads) - hit |= wait_all(); - free_grep_patterns(&opt); return !hit; } -- 1.7.0.1.370.gd3c5 -- 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