From: Alban Gruin <alban.gruin@gmail.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org, Johannes.Schindelin@gmx.de,
phillip.wood@dunelm.org.uk, gitster@pobox.com
Subject: Re: [PATCH v4 5/5] sequencer: directly call pick_commits() from complete_action()
Date: Wed, 27 Nov 2019 20:56:03 +0100 [thread overview]
Message-ID: <aa162f9c-9ae8-9844-6829-7fc0d9c50f9c@gmail.com> (raw)
In-Reply-To: <20191126184103.146421-1-jonathantanmy@google.com>
Hi Jonathan,
Le 26/11/2019 à 19:41, Jonathan Tan a écrit :
>> Currently, complete_action(), used by builtin/rebase.c to start a new
>> rebase, calls sequencer_continue() to do it. Before the former calls
>> pick_commits(), it
>>
>> - calls read_and_refresh_cache() -- this is unnecessary here as we've
>> just called require_clean_work_tree() in complete_action()
>
> require_clean_work_tree() and read_and_refresh_cache() seem to be
> different functions - can you explain why running the former is a good
> substitute for running the latter?
>
They both refresh the index.
require_clean_work_tree(), called when starting a new rebase, will also
check if there are any unstaged or uncommitted changes, in which case we
do not want to start a rebase.
This is not what we want when resuming a rebase (with `rebase
--continue'), because the changes might be the result of a conflict
resolution. In this case, the last commit is amended, and the rebase is
resumed.
>> - calls read_populate_opts() -- this is unnecessary as we're starting a
>> new rebase, so `opts' is fully populated
>
> My comment from [1] has not been addressed. Quoting it here:
>
>> So complete_action() (the function modified in this commit) is called
>> only by do_interactive_rebase() (in builtin/rebase.c), which is only
>> called by run_rebase_interactive() (in builtin/rebase.c) when command is
>> ACTION_NONE, so indeed, we're starting a new rebase. But where the
>> options fully populated? I see that in do_interactive_rebase(), it is
>> initialized with get_replay_opts(), but that seems different from
>> read_populate_opts().
>
> [1] https://lore.kernel.org/git/20191119204146.168001-1-jonathantanmy@google.com/
>
Sorry.
For the first part of your comment, I added a comment at the beginning
of the message, although I did _not_ include an analysis on when
complete_action() is used.
get_replay_opts() converts a `struct rebase_options' (which contains the
arguments passed to `git rebase') into a `struct replay_opts' which can
be used by the sequencer, whereas read_populate_opts() loads the options
from the disk.
So, when are they written to the disk? In do_interactive_rebase()
(builtin/rebase.c), after using get_replay_opts() to convert `opts' to
`replay', init_basic_state() is called, which calls write_basic_state(),
which write the options to the disk.
Then, until complete_action() is called, `opts' is not modified.
>> - loads the todo list -- this is unnecessary as we've just populated
>> the todo list in complete_action()
>
> Both functions indeed have their own todo lists that they pass to
> pick_commits(), but I don't see (at least, by glancing at the code) that
> both these todo lists are identical.
>
Near the end of complete_action(), the todo list is written to the disk.
The destination is obtained with rebase_path_todo().
read_populate_todo() will read a file and parse it. In the case of
`rebase -i', the location is obtained with rebase_path_todo(), and only
`total_nr' will be modified to contain the number of commands done and todo.
In the case of a new rebase, the done list might not be empty after
tajjimh skip_unnecessary_picks() from complete_action(). Skipped
commands are moved from the todo list to the done list. As `total_nr'
is not changed by skip_unnecessary_picks(), it is also equal to the
number of commands remaining in the todo list and in the done list. So,
when read_populate_todo() reads the list and the done list from the
disk, as they should not have been modified, `total_nr' should remain
the same, too.
The only thing that can change is the internal buffer (`buf'), because
skip_unnecessary_picks() don’t change it. Since
ag/sequencer-reduce-rewriting-todo, it is no longer a textual
representation of the todo list. Each command contains a pointer to a
location in the buffer and a length to represent its argument.
>> - commits any staged changes -- this is unnecessary as we're starting a
>> new rebase, so there are no staged changes
>> - calls record_in_rewritten() -- this is unnecessary as we're starting
>> a new rebase.
>
> OK - I don't know enough about the rebase mechanism to verify these, but
> these seem reasonable to me.
>
Cheers,
Alban
next prev parent reply other threads:[~2019-11-27 19:56 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190925201315.19722-1-alban.gruin@gmail.com>
2019-09-25 20:13 ` [PATCH v1 1/5] sequencer: update `total_nr' when adding an item to a todo list Alban Gruin
2019-10-02 2:10 ` Junio C Hamano
2019-10-02 8:06 ` Johannes Schindelin
2019-10-02 8:59 ` Junio C Hamano
2019-10-02 9:48 ` Johannes Schindelin
2019-10-02 18:03 ` Alban Gruin
2019-09-25 20:13 ` [PATCH v1 2/5] sequencer: update `done_nr' when skipping commands in " Alban Gruin
2019-09-25 20:13 ` [PATCH v1 3/5] sequencer: move the code writing total_nr on the disk to a new function Alban Gruin
2019-09-25 20:13 ` [PATCH v1 4/5] rebase: fill `squash_onto' in get_replay_opts() Alban Gruin
2019-09-27 13:30 ` Phillip Wood
2019-10-02 8:16 ` Johannes Schindelin
2019-10-02 9:32 ` Phillip Wood
2019-10-02 12:06 ` Johannes Schindelin
2019-09-25 20:13 ` [PATCH v1 5/5] sequencer: directly call pick_commits() from complete_action() Alban Gruin
2019-09-27 13:26 ` Phillip Wood
2019-10-02 8:20 ` Johannes Schindelin
2019-10-02 18:03 ` Alban Gruin
2019-10-02 2:38 ` Junio C Hamano
2019-10-02 18:37 ` Alban Gruin
2019-10-26 7:47 ` René Scharfe
2019-10-26 11:27 ` Alban Gruin
2019-10-28 1:39 ` Junio C Hamano
2019-10-28 3:20 ` Junio C Hamano
2019-09-25 20:20 ` [PATCH v1 0/5] Use complete_action's todo list to do the rebase Alban Gruin
2019-09-27 13:32 ` [PATCH v1 0/5] Use complete_action’s " Phillip Wood
2019-10-07 9:26 ` [PATCH v2 0/5] Use complete_action's " Alban Gruin
2019-10-07 9:26 ` [PATCH v2 1/5] sequencer: update `total_nr' when adding an item to a todo list Alban Gruin
2019-10-07 9:26 ` [PATCH v2 2/5] sequencer: update `done_nr' when skipping commands in " Alban Gruin
2019-10-07 9:26 ` [PATCH v2 3/5] sequencer: move the code writing total_nr on the disk to a new function Alban Gruin
2019-10-07 9:26 ` [PATCH v2 4/5] rebase: fill `squash_onto' in get_replay_opts() Alban Gruin
2019-10-07 9:26 ` [PATCH v2 5/5] sequencer: directly call pick_commits() from complete_action() Alban Gruin
2019-10-08 2:45 ` [PATCH v2 0/5] Use complete_action's todo list to do the rebase Junio C Hamano
2019-10-08 16:18 ` Alban Gruin
2019-10-14 12:49 ` Johannes Schindelin
2019-11-23 14:37 ` [PATCH v3 " Alban Gruin
2019-11-23 14:37 ` [PATCH v3 1/5] sequencer: update `total_nr' when adding an item to a todo list Alban Gruin
2019-11-23 14:37 ` [PATCH v3 2/5] sequencer: update `done_nr' when skipping commands in " Alban Gruin
2019-11-23 14:37 ` [PATCH v3 3/5] sequencer: move the code writing total_nr on the disk to a new function Alban Gruin
2019-11-23 14:37 ` [PATCH v3 4/5] rebase: fill `squash_onto' in get_replay_opts() Alban Gruin
2019-11-23 14:37 ` [PATCH v3 5/5] sequencer: directly call pick_commits() from complete_action() Alban Gruin
2019-11-24 17:43 ` [PATCH v4 0/5] Use complete_action's todo list to do the rebase Alban Gruin
2019-11-24 17:43 ` [PATCH v4 1/5] sequencer: update `total_nr' when adding an item to a todo list Alban Gruin
2019-11-24 17:43 ` [PATCH v4 2/5] sequencer: update `done_nr' when skipping commands in " Alban Gruin
2019-11-24 17:43 ` [PATCH v4 3/5] sequencer: move the code writing total_nr on the disk to a new function Alban Gruin
2019-11-24 17:43 ` [PATCH v4 4/5] rebase: fill `squash_onto' in get_replay_opts() Alban Gruin
2019-11-26 18:27 ` Jonathan Tan
2019-11-24 17:43 ` [PATCH v4 5/5] sequencer: directly call pick_commits() from complete_action() Alban Gruin
2019-11-26 18:41 ` Jonathan Tan
2019-11-27 19:56 ` Alban Gruin [this message]
2019-11-27 20:09 ` Alban Gruin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa162f9c-9ae8-9844-6829-7fc0d9c50f9c@gmail.com \
--to=alban.gruin@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).