add: warn when adding an embedded repository
[gitweb.git] / builtin / grep.c
index 72a19699a829646eb5261d934ceebff16b5d4f4d..7df9c253eebb3053693769d14efe0551393dfd4d 100644 (file)
@@ -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