diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-06-02 15:06:05 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-02 15:06:06 +0900 |
commit | 36dcb573374f267125a35a0d964707b527dd637d (patch) | |
tree | ddac88242f6b15e7b26bdd1fd83121c347864bbe /builtin | |
parent | Merge branch 'jk/diff-blob' (diff) | |
parent | grep: assert that threading is enabled when calling grep_{lock,unlock} (diff) | |
download | tgif-36dcb573374f267125a35a0d964707b527dd637d.tar.xz |
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')
-rw-r--r-- | builtin/grep.c | 23 | ||||
-rw-r--r-- | builtin/pack-objects.c | 4 |
2 files changed, 22 insertions, 5 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 72a19699a8..7df9c253ee 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); +#ifdef NO_PTHREADS + 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; + } +#endif } return st; @@ -495,6 +506,8 @@ static void compile_submodule_options(const struct grep_opt *opt, break; case GREP_PATTERN_TYPE_UNSPECIFIED: break; + 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); #else + if (num_threads) + warning(_("no threads support, ignoring --threads")); num_threads = 0; #endif diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 80439047aa..f672225def 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -2483,8 +2483,10 @@ static int git_pack_config(const char *k, const char *v, void *cb) die("invalid number of threads specified (%d)", delta_search_threads); #ifdef NO_PTHREADS - if (delta_search_threads != 1) + if (delta_search_threads != 1) { warning("no threads support, ignoring %s", k); + delta_search_threads = 0; + } #endif return 0; } |