mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
grep: move thread initialization a little lower
Originally, we set up the threads for grep before parsing
the non-option arguments. In 53b8d931b
(grep: disable
threading in non-worktree case, 2011-12-12), the thread code
got bumped lower in the function because it now needed to
know whether we got any revision arguments.
That put a big block of code in between the parsing of revs
and the parsing of pathspecs, both of which share some loop
variables. That makes it harder to read the code than the
original, where the shared loops were right next to each
other.
Let's bump the thread initialization until after all of the
parsing is done.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
5588dbffbd
commit
a0fe2b0d23
|
@ -1169,6 +1169,20 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The rest are paths */
|
||||||
|
if (!seen_dashdash) {
|
||||||
|
int j;
|
||||||
|
for (j = i; j < argc; j++)
|
||||||
|
verify_filename(prefix, argv[j], j == i);
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_pathspec(&pathspec, 0,
|
||||||
|
PATHSPEC_PREFER_CWD |
|
||||||
|
(opt.max_depth != -1 ? PATHSPEC_MAXDEPTH_VALID : 0),
|
||||||
|
prefix, argv + i);
|
||||||
|
pathspec.max_depth = opt.max_depth;
|
||||||
|
pathspec.recursive = 1;
|
||||||
|
|
||||||
#ifndef NO_PTHREADS
|
#ifndef NO_PTHREADS
|
||||||
if (list.nr || cached || show_in_pager)
|
if (list.nr || cached || show_in_pager)
|
||||||
num_threads = 0;
|
num_threads = 0;
|
||||||
|
@ -1190,20 +1204,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The rest are paths */
|
|
||||||
if (!seen_dashdash) {
|
|
||||||
int j;
|
|
||||||
for (j = i; j < argc; j++)
|
|
||||||
verify_filename(prefix, argv[j], j == i);
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_pathspec(&pathspec, 0,
|
|
||||||
PATHSPEC_PREFER_CWD |
|
|
||||||
(opt.max_depth != -1 ? PATHSPEC_MAXDEPTH_VALID : 0),
|
|
||||||
prefix, argv + i);
|
|
||||||
pathspec.max_depth = opt.max_depth;
|
|
||||||
pathspec.recursive = 1;
|
|
||||||
|
|
||||||
if (recurse_submodules) {
|
if (recurse_submodules) {
|
||||||
gitmodules_config();
|
gitmodules_config();
|
||||||
compile_submodule_options(&opt, &pathspec, cached, untracked,
|
compile_submodule_options(&opt, &pathspec, cached, untracked,
|
||||||
|
|
Loading…
Reference in a new issue