git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 7/8] pack-objects: fix buggy warning about threads under NO_PTHREADS=YesPlease

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 16, 2017, 22:21 UTC
Message-ID
<20170416222102.2320-8-avarab@gmail.com>
In-Reply-To
<20170416222102.2320-1-avarab@gmail.com>

Fix a buggy warning about threads under NO_PTHREADS=YesPlease. Due to re-using the delta_search_threads variable for both the state of the "pack.threads" config & the --threads option setting "pack.threads" but not supplying --threads would trigger the warning for both "pack.threads" & --threads.

Solve this bug by resetting the delta_search_threads variable in git_pack_config(), it might then be set by --threads again and be subsequently warned about, as the test I'm changing here asserts.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/pack-objects.c | 4 +++-
 t/t5300-pack-object.sh | 3 +--
 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 84af7c2324..905465e91f 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2472,8 +2472,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;
 	}
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 6bb6a8981b..50e1ae87a4 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -445,8 +445,7 @@ test_expect_success !PTHREADS,!GETTEXT_POISON 'pack-objects --threads=N or pack.
 	git -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&
 	cat err &&
 	grep ^warning: err >warnings &&
-	test_line_count = 2 warnings &&
-	grep "no threads support, ignoring --threads" err &&
+	test_line_count = 1 warnings &&
 	grep "no threads support, ignoring pack\.threads" err &&
 	git -c pack.threads=2 pack-objects --threads=4 --stdout --all </dev/null >/dev/null 2>err &&
 	grep ^warning: err >warnings &&
-- 
2.11.0
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 8 of 9 in “grep threading cleanup & tests”
  1. 0/8 grep threading cleanup & testsÆvar Arnfjörð Bjarmason, Apr 16, 2017
  2. 1/8 grep: assert that threading is enabled when calling grep_{lock,unlock}Ævar Arnfjörð Bjarmason, Apr 16, 2017
  3. 2/8 grep: add tests for --threads=N and grep.threadsÆvar Arnfjörð Bjarmason, Apr 16, 2017
  4. 3/8 grep: don't redundantly compile throwaway patterns under threadingÆvar Arnfjörð Bjarmason, Apr 16, 2017
  5. 4/8 grep: skip pthreads overhead when using one threadÆvar Arnfjörð Bjarmason, Apr 16, 2017
  6. 5/8 tests: add a PTHREADS prerequisiteÆvar Arnfjörð Bjarmason, Apr 16, 2017
  7. 8/8 grep: given --threads with NO_PTHREADS=YesPlease, warnÆvar Arnfjörð Bjarmason, Apr 16, 2017
  8. 7/8 pack-objects: fix buggy warning about threads under NO_PTHREADS=YesPleaseÆvar Arnfjörð Bjarmason, Apr 16, 2017
  9. 6/8 pack-object & index-pack: add test for --threads warning under NO_PTHREADSÆvar Arnfjörð Bjarmason, Apr 16, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.