path: root/builtin/grep.c
diff options
authorJunio C Hamano <>2017-06-02 06:06:05 (GMT)
committerJunio C Hamano <>2017-06-02 06:06:06 (GMT)
commit36dcb573374f267125a35a0d964707b527dd637d (patch)
treeddac88242f6b15e7b26bdd1fd83121c347864bbe /builtin/grep.c
parent7ef0d047386a1932dc4a8b1008d851b0fe47f978 (diff)
parent8df4c2953f228020438eb53a7d54470c922ce9cc (diff)
Merge branch 'ab/grep-preparatory-cleanup'
The internal implementation of "git grep" has seen some clean-up. * ab/grep-preparatory-cleanup: (31 commits) grep: assert that threading is enabled when calling grep_{lock,unlock} grep: given --threads with NO_PTHREADS=YesPlease, warn pack-objects: fix buggy warning about threads pack-objects & index-pack: add test for --threads warning test-lib: add a PTHREADS prerequisite grep: move is_fixed() earlier to avoid forward declaration grep: change internal *pcre* variable & function names to be *pcre1* grep: change the internal PCRE macro names to be PCRE1 grep: factor test for \0 in grep patterns into a function grep: remove redundant regflags assignments grep: catch a missing enum in switch statement perf: add a comparison test of log --grep regex engines with -F perf: add a comparison test of log --grep regex engines perf: add a comparison test of grep regex engines with -F perf: add a comparison test of grep regex engines perf: emit progress output when unpacking & building perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't do grep: add tests to fix blind spots with \0 patterns grep: prepare for testing binary regexes containing rx metacharacters grep: add a test helper function for less verbose -f \0 tests ...
Diffstat (limited to 'builtin/grep.c')
1 files changed, 19 insertions, 4 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 72a1969..7df9c25 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -73,14 +73,14 @@ static pthread_mutex_t grep_mutex;
static inline void grep_lock(void)
- if (num_threads)
- pthread_mutex_lock(&grep_mutex);
+ assert(num_threads);
+ pthread_mutex_lock(&grep_mutex);
static inline void grep_unlock(void)
- if (num_threads)
- pthread_mutex_unlock(&grep_mutex);
+ assert(num_threads);
+ pthread_mutex_unlock(&grep_mutex);
/* Signalled when a new work_item is added to todo. */
@@ -289,6 +289,17 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)
if (num_threads < 0)
die(_("invalid number of threads specified (%d) for %s"),
num_threads, var);
+ else if (num_threads && num_threads != 1) {
+ /*
+ * TRANSLATORS: %s is the configuration
+ * variable for tweaking threads, currently
+ * grep.threads
+ */
+ warning(_("no threads support, ignoring %s"), var);
+ num_threads = 0;
+ }
return st;
@@ -495,6 +506,8 @@ static void compile_submodule_options(const struct grep_opt *opt,
+ default:
+ die("BUG: Added a new grep pattern type without updating switch statement");
for (pattern = opt->pattern_list; pattern != NULL;
@@ -1229,6 +1242,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
else if (num_threads < 0)
die(_("invalid number of threads specified (%d)"), num_threads);
+ if (num_threads)
+ warning(_("no threads support, ignoring --threads"));
num_threads = 0;