pack-objects: fix buggy warning about threads
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 25 May 2017 19:45:33 +0000 (19:45 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 May 2017 03:52:37 +0000 (12:52 +0900)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
t/t5300-pack-object.sh
index 0fe35d1b5aebd74116d66d5414bdabf19baf7d97..f1baf05dfe31dc9bbb91c1b6ff44c123fa1b3d38 100644 (file)
@@ -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;
        }
index 6ed23ee1d209bfa2bf4c607907eb35a37b478313..9c68b992511b7098df0570ca37e0add468a8a093 100755 (executable)
@@ -447,7 +447,7 @@ test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'pack-objects --threads=N or pack.
 
        git -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&
        grep ^warning: err >warnings &&
-       test_must_fail test_line_count = 1 warnings &&
+       test_line_count = 1 warnings &&
        grep -F "no threads support, ignoring pack.threads" err &&
 
        git -c pack.threads=2 pack-objects --threads=4 --stdout --all </dev/null >/dev/null 2>err &&