summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/pack-objects.c6
-rw-r--r--thread-utils.h4
2 files changed, 8 insertions, 2 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index d39193453a..a71523706a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1972,8 +1972,6 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
init_threaded_search();
- if (!delta_search_threads) /* --threads=0 means autodetect */
- delta_search_threads = online_cpus();
if (delta_search_threads <= 1) {
find_deltas(list, &list_size, window, depth, processed);
cleanup_threaded_search();
@@ -2685,6 +2683,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
pack_compression_level = Z_DEFAULT_COMPRESSION;
else if (pack_compression_level < 0 || pack_compression_level > Z_BEST_COMPRESSION)
die("bad pack compression level %d", pack_compression_level);
+
+ if (!delta_search_threads) /* --threads=0 means autodetect */
+ delta_search_threads = online_cpus();
+
#ifdef NO_PTHREADS
if (delta_search_threads != 1)
warning("no threads support, ignoring --threads");
diff --git a/thread-utils.h b/thread-utils.h
index 6fb98c333c..d9a769d190 100644
--- a/thread-utils.h
+++ b/thread-utils.h
@@ -7,5 +7,9 @@
extern int online_cpus(void);
extern int init_recursive_mutex(pthread_mutex_t*);
+#else
+
+#define online_cpus() 1
+
#endif
#endif /* THREAD_COMPAT_H */