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

Re: [PATCH 02/10] bisect--helper: reimplement `bisect_next` and `bisect_auto_next` shell functions in C

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 27, 2020, 16:41 UTC
Message-ID
<xmqqwo88f0do.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAN7CjDDwgR=y8gyYmDzmuTW3AKvb1N=EdCtH-8Tr7T=b6cG5gQ@mail.gmail.com>
"Miriam R." <mirucam@gmail.com> writes:
Show 23 quoted lines
>> It would be surprising if this code were correct.  It may be that it
>> happens to (appear to) work because parents of the commit hasn't
>> been painted and calling the helper only clears the mark from the
>> commit (so we won't see repeated "painting down to the root commit")
>> in which case this might be an extremely expensive looking variant
>> of
>>
>>         commit->object.flags &= ~ALL_REV_FLAGS;
>>
>> that only confuses the readers.
>>
>> Even then, I think by clearing bits like SEEN from commit, it breaks
>> the revision traversal machinery---for example, doesn't this mean
>> that the commit we just processed can be re-visited by
>> get_revision() without deduping in a history with forks and merges?
>>
>> Has this been shown to any of your mentors before sending it to the
>> list?
>
> Adding clear_commit_marks() was a suggestion of a previous review of this patch:
> https://public-inbox.org/git/nycvar.QRO.7.76.6.2001301619340.46@tvgsbejvaqbjf.bet/
>
> And of course, my mentor always reviews my patch series before sending.

OK, I just didn't know how you and your mentors work. Some leave their door open for mentees and help them when asked but otherwise act as an ordinary reviewer who somehow prioritises reviewing the work by their mentees. So your mentors may be a better source of information why this piece of code, which I still do not know how it could be correct, is supposed to work. Good.

After reading the above URL, I think you may have misread the suggestion you were given. Resetting using clear_commit_marks() may be necessary, but you do so when you finished walking so that you can do unrelated revision walk later. For that, you clear the flag bits after the while() loop that asks get_revision() to yield commits are done, using the initial set of commits that you used to start iteration.

That is how bisect.c::check_ancestors() work, that is
 - it initializes a rev_info 'revs' from an array of commit rev[]
 - it lets bisect_common() use the 'revs', which is allowed to
   smudge the flag bits of commit objects.
 - it uses clear_commit_marks_many() to clear the flags of the
   commits whose flag bits may have been smudged and their
   ancestors, recursively.  In order to use as the starting points,
   the original array of commit rev[] that started the revision
   traversal is used.
Previous: Miriam R.Next: Miriam R.
Message 8 of 20 in “Finish converting git bisect to C part 2”
  1. Miriam RubioFeb 26, 2020
  2. 01/10 bisect--helper: introduce new `write_in_file()` functionMiriam Rubio, Feb 26, 2020
  3. Junio C HamanoFeb 26, 2020
  4. 03/10 bisect--helper: finish porting `bisect_start()` to CMiriam Rubio, Feb 26, 2020
  5. 02/10 bisect--helper: reimplement `bisect_next` and `bisect_auto_next` shell functions in CMiriam Rubio, Feb 26, 2020
  6. Junio C HamanoFeb 26, 2020
  7. Miriam R.Feb 27, 2020
  8. Junio C HamanoFeb 27, 2020
  9. Miriam R.Mar 6, 2020
  10. Junio C HamanoMar 6, 2020
  11. Christian CouderMar 11, 2020
  12. 04/10 bisect--helper: retire `--bisect-clean-state` subcommandMiriam Rubio, Feb 26, 2020
  13. 05/10 bisect--helper: retire `--next-all` subcommandMiriam Rubio, Feb 26, 2020
  14. 06/10 bisect--helper: reimplement `bisect_autostart` shell function in CMiriam Rubio, Feb 26, 2020
  15. Johannes SchindelinFeb 27, 2020
  16. 07/10 bisect--helper: reimplement `bisect_state` & `bisect_head` shell functions in CMiriam Rubio, Feb 26, 2020
  17. Johannes SchindelinFeb 27, 2020
  18. 08/10 bisect--helper: retire `--check-expected-revs` subcommandMiriam Rubio, Feb 26, 2020
  19. 09/10 bisect--helper: retire `--write-terms` subcommandMiriam Rubio, Feb 26, 2020
  20. 10/10 bisect--helper: retire `--bisect-autostart` subcommandMiriam Rubio, Feb 26, 2020

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.