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

Re: [PATCH v1 5/5] sequencer: directly call pick_commits() from complete_action()

From
Alban Gruin <alban.gruin@gmail.com>
Date
Oct 2, 2019, 18:37 UTC
Message-ID
<c276de00-fffb-c483-e1b9-526052544fe8@gmail.com>
In-Reply-To
<xmqq5zl7hnwe.fsf@gitster-ct.c.googlers.com>
Hi Junio,
Le 02/10/2019 à 04:38, Junio C Hamano a écrit :
Show 21 quoted lines
> Alban Gruin <alban.gruin@gmail.com> writes:
> 
>> Currently, complete_action() calls sequencer_continue() to do the
>> rebase.  Even though the former already has the todo list, the latter
>> loads it from the disk and parses it.  Calling directly pick_commits()
>> from complete_action() avoids this unnecessary round trip.
>>
>> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
>> ---
>>  sequencer.c | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> All the earlier steps in this series are necessary because the
> inconsistencies caused by not doing things the code updated by the
> earlier steps do (e.g. leaving number of commits recorded in
> total_nr and done_nr stale) were masked by re-reading the info from
> the on-disk file.  And this step exposes these inconsistencies
> because the extra reading from the file no longer happens.
> 
> That is my reading of the series---did I get it right?
> 
Yes.
Show 23 quoted lines
> I wonder if that can be stated clearly in the log message of the
> earlier steps.
> 
> For example, by reading 1/5 or 2/5 alone, it would be natural for
> readers to wonder why the original code that did not update done_nr
> correctly terminated after going through the todo list (you would
> expect that when done reaches total you are finished, so if one of
> these variables are not maintained correctly, your termination
> condition may be borked), and then by knowing that the current code
> more-or-less works correctly by not terminating too early or barfing
> to say it ran out of things to do prematurely, the next thing
> readers would wonder is if these patches introduce new bugs by
> incrementing these variables twice (iow, "does the author of the
> patch missed other places where these variables are correctly
> updated?")
> 
> 1/5 for example talks about the variable mostly being used by
> prompts, which may be useful to reduce worries by readers about
> correctness (iow, "well, if it is only showing wrong number in the
> prompts and does not affect correctness otherwise, perhaps that was
> why the current code that is buggy did not behave incorrectly").
> But I suspect that it is not why these changes in the earlier steps
> are acceptable or are right things to do.

Interestingly, it is the only reason for these two patches. If you skip them both, t34??-*.sh will not fail, only t9903-bash-prompt.sh will. This is because `total_nr' does not reflect the real number of items in a todo list, but the number of steps, done *and* remaining. When a rebase is resumed, some commands may already have been run, and are no longer part of the todo list. So, it’s not used to determine whether or not the rebase is done. `nr' is used for this purpose. `done_nr' and `total_nr' are just used for user interaction.

Show 16 quoted lines
>  So, perhaps replace the
> "these are used only in prompts and the numbers being wrong does not
> affect correctness" comments from them with:
> 
>     By forgetting to update the variable, the original code made it
>     not reflect the reality, but this flaw was masked by the code
>     calling (sometimes unnecessarily) read_todo_list() again to
>     update the variable to its correct value before the next action
>     happens.  At the end of this series, the unnecessary call will
>     be removed and the inconsistency addressed by this patch would
>     start to matter.
> 
> or something like that (assuming that the answer to the first
> question I asked in this message is "yes", that is), or a more
> concise version of it?
> 
I will do so.

Cheers, Alban

> Thanks.
> 
Previous: Junio C HamanoNext: René Scharfe
Message 19 of 50 in “sequencer: update `total_nr' when adding an item to a todo list”
  1. 1/5 sequencer: update `total_nr' when adding an item to a todo listAlban Gruin, Sep 25, 2019
  2. Junio C HamanoOct 2, 2019
  3. Johannes SchindelinOct 2, 2019
  4. Junio C HamanoOct 2, 2019
  5. Johannes SchindelinOct 2, 2019
  6. Alban GruinOct 2, 2019
  7. 2/5 sequencer: update `done_nr' when skipping commands in a todo listAlban Gruin, Sep 25, 2019
  8. 3/5 sequencer: move the code writing total_nr on the disk to a new functionAlban Gruin, Sep 25, 2019
  9. 4/5 rebase: fill `squash_onto' in get_replay_opts()Alban Gruin, Sep 25, 2019
  10. Phillip WoodSep 27, 2019
  11. Johannes SchindelinOct 2, 2019
  12. Phillip WoodOct 2, 2019
  13. Johannes SchindelinOct 2, 2019
  14. 5/5 sequencer: directly call pick_commits() from complete_action()Alban Gruin, Sep 25, 2019
  15. Phillip WoodSep 27, 2019
  16. Johannes SchindelinOct 2, 2019
  17. Alban GruinOct 2, 2019
  18. Junio C HamanoOct 2, 2019
  19. Alban GruinOct 2, 2019
  20. René ScharfeOct 26, 2019
  21. Alban GruinOct 26, 2019
  22. Junio C HamanoOct 28, 2019
  23. Junio C HamanoOct 28, 2019
  24. 0/5 Use complete_action's todo list to do the rebaseAlban Gruin, Sep 25, 2019
  25. Phillip WoodSep 27, 2019
  26. 0/5 Use complete_action's todo list to do the rebaseAlban Gruin, Oct 7, 2019
  27. 1/5 sequencer: update `total_nr' when adding an item to a todo listAlban Gruin, Oct 7, 2019
  28. 2/5 sequencer: update `done_nr' when skipping commands in a todo listAlban Gruin, Oct 7, 2019
  29. 3/5 sequencer: move the code writing total_nr on the disk to a new functionAlban Gruin, Oct 7, 2019
  30. 4/5 rebase: fill `squash_onto' in get_replay_opts()Alban Gruin, Oct 7, 2019
  31. 5/5 sequencer: directly call pick_commits() from complete_action()Alban Gruin, Oct 7, 2019
  32. Junio C HamanoOct 8, 2019
  33. Alban GruinOct 8, 2019
  34. Johannes SchindelinOct 14, 2019
  35. 0/5 Use complete_action's todo list to do the rebaseAlban Gruin, Nov 23, 2019
  36. 1/5 sequencer: update `total_nr' when adding an item to a todo listAlban Gruin, Nov 23, 2019
  37. 4/5 rebase: fill `squash_onto' in get_replay_opts()Alban Gruin, Nov 23, 2019
  38. 5/5 sequencer: directly call pick_commits() from complete_action()Alban Gruin, Nov 23, 2019
  39. 3/5 sequencer: move the code writing total_nr on the disk to a new functionAlban Gruin, Nov 23, 2019
  40. 2/5 sequencer: update `done_nr' when skipping commands in a todo listAlban Gruin, Nov 23, 2019
  41. 0/5 Use complete_action's todo list to do the rebaseAlban Gruin, Nov 24, 2019
  42. 1/5 sequencer: update `total_nr' when adding an item to a todo listAlban Gruin, Nov 24, 2019
  43. 2/5 sequencer: update `done_nr' when skipping commands in a todo listAlban Gruin, Nov 24, 2019
  44. 4/5 rebase: fill `squash_onto' in get_replay_opts()Alban Gruin, Nov 24, 2019
  45. Jonathan TanNov 26, 2019
  46. 3/5 sequencer: move the code writing total_nr on the disk to a new functionAlban Gruin, Nov 24, 2019
  47. 5/5 sequencer: directly call pick_commits() from complete_action()Alban Gruin, Nov 24, 2019
  48. Jonathan TanNov 26, 2019
  49. Alban GruinNov 27, 2019
  50. Alban GruinNov 27, 2019

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.