Re: [PATCH 08/10] revert: Introduce HEAD, TODO files to persist state, plan
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Jun 1, 2011, 15:28 UTC
- Message-ID
- <BANLkTino5gmfXjeOVih7+LHcMu1usPWAoQ@mail.gmail.com>
- In-Reply-To
- <20110526161102.GC24931@elie>
Hi Jonathan and others,
Jonathan Nieder writes:
Show 24 quoted lines
> Ramkumar Ramachandra wrote:
> Almost there. To comfort overly-worried people like me that think we
> have not finished converted all die() calls yet, wouldn't this need to
> look like
>
> persist_head(head);
> while ((commit = ...)) {
> int status_or_error;
>
> /*
> * Checkpoint. If do_pick_commit exits, make sure the user
> * can still use "git cherry-pick --continue" to recover.
> */
> persist_todo(revs.commits, opts);
>
> status_or_error = do_pick_commit(...);
> if (status_or_error)
> return status_or_error;
> }
>
> /* Success! */
> remove_todo(opts);
> remove_head();
> return 0;It's a little embarrassing, but I'm not able to figure out how to persist the TODO early. prepare_revs() sets up the revision walker and populates the rev_info struct: it contains a commit_list * in its commits member, but I apparently can't access those directly -- I went through some literature about revision walking and inspected how get_revision must be used to iterate over all the individual commits. Now, to persist the TODO, I need a commit_list to use: is there some API I can use to avoid iterating over all the commits twice? Once to populate the commit_list to persist the TODO, and the second time to actually pick them?
Thanks.
-- Ram