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
Junio C Hamano <gitster@pobox.com>
Date
Oct 28, 2019, 03:20 UTC
Message-ID
<xmqqftjda745.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<xmqqeeyxbqc6.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> So I'd probably just send a "fixup!"to be queued on top of the
> series to fix a leak in 'next' for now, remind the maintainer not to
> merge it to 'master' before the release, and once the upcoming
> release is made, send another reminder to the maintainer to squash
> the "fixup!" in before rebuilding 'next', if I owned this series.

This is based on René's suggestion, but seeing the pre-context of this fix, many of the error code path, after an error return from edit_todo_list() has been handled, can follow the pattern of this fix to jump to the cleanup label after losing their own calls to todo_list_release(). An obvious advantage of doing so is that it future-proofs the codepath---the todo-list structure may not stay to be the only thing that holds resources that need cleaned up.

 sequencer.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index b395dd6e11..ec0b793fc5 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -5140,14 +5140,18 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 		return error_errno(_("could not write '%s'"), todo_file);
 	}
 
+	res = -1;
+
 	if (checkout_onto(r, opts, onto_name, &oid, orig_head))
-		return -1;
+		goto cleanup;
 
 	if (require_clean_work_tree(r, "rebase", "", 1, 1))
-		return -1;
+		goto cleanup;
 
 	todo_list_write_total_nr(&new_todo);
 	res = pick_commits(r, &new_todo, opts);
+
+cleanup:
 	todo_list_release(&new_todo);
 
 	return res;
Previous: Junio C HamanoNext: Alban Gruin
Message 23 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.