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

Re: [PATCH v2 27/29] pack-objects: fix buggy warning about threads

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 15, 2017, 17:16 UTC
Message-ID
<CACBZZX61W_MxJJ=YFEGLCk-ktb9xj=D-_jet02McriKJHiHO9g@mail.gmail.com>
In-Reply-To
<xmqqfug6v6l3.fsf@gitster.mtv.corp.google.com>
On Mon, May 15, 2017 at 10:59 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 78 quoted lines
> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> 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 0fe35d1b5a..f1baf05dfe 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 1629fa80b0..0ec25c4966 100755
>> --- a/t/t5300-pack-object.sh
>> +++ b/t/t5300-pack-object.sh
>> @@ -445,8 +445,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 &&
>>       cat err &&
>>       grep ^warning: err >warnings &&
>> -     test_line_count = 2 warnings &&
>> -     grep -F "no threads support, ignoring --threads" err &&
>> +     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 &&
>>       grep ^warning: err >warnings &&
>
> Commenting on both 26 and 27.
>
> The usual way we document a known breakage to be fixed is to write a
> test that checks for the desired outcome with test_expect_failure,
> and when a patch corrects the behaviour we just flip it to expect
> success instead.  On the other hand, when we document a behaviour
> that is accepted/acceptable we would have a test that checks for the
> then-accepted behaviour with test_expect_success, and a patch that
> improves the behaviour would update the expectation.
>
> This follows the second pattern, even though the log message for the
> patches claim this is about an existing bug and its fix.
>
> Now, I am not saying (at least not yet) that 26 & 27 violates the
> established practice and they must be changed to expect seeing only
> one line of output in warnings with test_expect_failure in patch 26
> which is flipped to test_expect_success in patch 27.  Yes, it does
> not follow the usual pattern, but it gives a good food-for-thought.
>
> Perhaps our usual pattern may be suboptimal in illustrating in what
> way the current behaviour is not desirable, and the way these two
> patches document the current breakage and then documents the fixed
> behaviour may be a better example to follow?  With our usual way, it
> is not apparent until you actually run the tests with the current
> code what the questionable current behaviour is, but with the way
> patch 26 is written, we can tell that two warnings are given,
> instead of one.
>
> I dunno.  What do others think?

I think it makes sense to make use of test_expect_failure here. I'll do that in v3.

Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 39 of 42 in “Easy to review grep & pre-PCRE changes”
  1. 00/29 Easy to review grep & pre-PCRE changesÆvar Arnfjörð Bjarmason, May 13, 2017
  2. 01/29 Makefile & configure: reword inaccurate comment about PCREÆvar Arnfjörð Bjarmason, May 13, 2017
  3. 02/29 grep & rev-list doc: stop promising libpcre for --perl-regexpÆvar Arnfjörð Bjarmason, May 13, 2017
  4. 04/29 log: add exhaustive tests for pattern style options & configÆvar Arnfjörð Bjarmason, May 13, 2017
  5. Junio C HamanoMay 15, 2017
  6. Ævar Arnfjörð BjarmasonMay 15, 2017
  7. Junio C HamanoMay 16, 2017
  8. 05/29 grep: add a test asserting that --perl-regexp dies when !PCREÆvar Arnfjörð Bjarmason, May 13, 2017
  9. 03/29 test-lib: rename the LIBPCRE prerequisite to PCREÆvar Arnfjörð Bjarmason, May 13, 2017
  10. 06/29 grep: add a test for backreferences in PCRE patternsÆvar Arnfjörð Bjarmason, May 13, 2017
  11. 07/29 grep: change non-ASCII -i test to stop using --debugÆvar Arnfjörð Bjarmason, May 13, 2017
  12. 08/29 grep: add tests for --threads=N and grep.threadsÆvar Arnfjörð Bjarmason, May 13, 2017
  13. 09/29 grep: amend submodule recursion test for regex engine testingÆvar Arnfjörð Bjarmason, May 13, 2017
  14. 10/29 grep: add tests for grep pattern types being passed to submodulesÆvar Arnfjörð Bjarmason, May 13, 2017
  15. 11/29 grep: add a test helper function for less verbose -f \0 testsÆvar Arnfjörð Bjarmason, May 13, 2017
  16. 12/29 grep: prepare for testing binary regexes containing rx metacharactersÆvar Arnfjörð Bjarmason, May 13, 2017
  17. 13/29 grep: add tests to fix blind spots with \0 patternsÆvar Arnfjörð Bjarmason, May 13, 2017
  18. 14/29 perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't doÆvar Arnfjörð Bjarmason, May 13, 2017
  19. 15/29 perf: emit progress output when unpacking & buildingÆvar Arnfjörð Bjarmason, May 13, 2017
  20. 16/29 perf: add a performance comparison test of grep -G, -E and -PÆvar Arnfjörð Bjarmason, May 13, 2017
  21. 18/29 grep: catch a missing enum in switch statementÆvar Arnfjörð Bjarmason, May 13, 2017
  22. Junio C HamanoMay 15, 2017
  23. Ævar Arnfjörð BjarmasonMay 15, 2017
  24. 17/29 perf: add a performance comparison of fixed-string grepÆvar Arnfjörð Bjarmason, May 13, 2017
  25. 20/29 grep: remove redundant `regflags &= ~REG_EXTENDED` assignmentsÆvar Arnfjörð Bjarmason, May 13, 2017
  26. Junio C HamanoMay 15, 2017
  27. Ævar Arnfjörð BjarmasonMay 15, 2017
  28. 19/29 grep: remove redundant regflags assignment under PCREÆvar Arnfjörð Bjarmason, May 13, 2017
  29. 21/29 grep: factor test for \0 in grep patterns into a functionÆvar Arnfjörð Bjarmason, May 13, 2017
  30. Junio C HamanoMay 15, 2017
  31. Ævar Arnfjörð BjarmasonMay 15, 2017
  32. 22/29 grep: change the internal PCRE macro names to be PCRE1Ævar Arnfjörð Bjarmason, May 13, 2017
  33. 23/29 grep: change internal *pcre* variable & function names to be *pcre1*Ævar Arnfjörð Bjarmason, May 13, 2017
  34. 25/29 test-lib: add a PTHREADS prerequisiteÆvar Arnfjörð Bjarmason, May 13, 2017
  35. 26/29 pack-objects & index-pack: add test for --threads warningÆvar Arnfjörð Bjarmason, May 13, 2017
  36. 24/29 grep: move is_fixed() earlier to avoid forward declarationÆvar Arnfjörð Bjarmason, May 13, 2017
  37. 27/29 pack-objects: fix buggy warning about threadsÆvar Arnfjörð Bjarmason, May 13, 2017
  38. Junio C HamanoMay 15, 2017
  39. Ævar Arnfjörð BjarmasonMay 15, 2017
  40. 28/29 grep: given --threads with NO_PTHREADS=YesPlease, warnÆvar Arnfjörð Bjarmason, May 13, 2017
  41. 29/29 grep: assert that threading is enabled when calling grep_{lock,unlock}Ævar Arnfjörð Bjarmason, May 13, 2017
  42. Junio C HamanoMay 15, 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.