]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/grep.c
grep: refactor grep_objects loop into its own function
authorJonathan Nieder <jrnieder@gmail.com>
Sat, 12 Jun 2010 16:31:18 +0000 (11:31 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 13 Jun 2010 16:15:09 +0000 (09:15 -0700)
commit30d00c395e3fb9f104a3f4a85f06a039c989cd8d
tree8c587e5e49d288a58f2b5fe95a93e1df3bcf9be0
parent7c42e390a37a11b1f7a77f5f07c261a8f930663a
grep: refactor grep_objects loop into its own function

Simplify cmd_grep by splitting off the loop that finds matches in a
list of trees.  So now the main part of cmd_grep looks like:

if (!use_index) {
int hit = grep_directory(&opt, paths);
if (use_threads)
hit |= wait_all();
return !hit;
}
if (!list.nr) {
if (!cached)
setup_work_tree();
int hit = grep_cache(&opt, paths, cached);
if (use_threads)
hit |= wait_all;
return !hit;
}
hit = grep_objects(&opt, path, &list);
if (use_threads)
hit |= wait_all();
return !hit;

and is ripe for further refactoring.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c