revisions API users: add "goto cleanup" for release_revisions()

Add a release_revisions() to various users of "struct rev_info" which
requires a minor refactoring to a "goto cleanup" pattern to use that
function.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2022-04-13 22:01:40 +02:00
committed by Junio C Hamano
parent 5e480176fe
commit 0139c58ab9
6 changed files with 55 additions and 24 deletions

View File

@ -5354,6 +5354,7 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
int rebase_merges = flags & TODO_LIST_REBASE_MERGES;
int reapply_cherry_picks = flags & TODO_LIST_REAPPLY_CHERRY_PICKS;
int skipped_commit = 0;
int ret = 0;
repo_init_revisions(r, &revs, NULL);
revs.verbose_header = 1;
@ -5377,14 +5378,20 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
pp.fmt = revs.commit_format;
pp.output_encoding = get_log_output_encoding();
if (setup_revisions(argc, argv, &revs, NULL) > 1)
return error(_("make_script: unhandled options"));
if (setup_revisions(argc, argv, &revs, NULL) > 1) {
ret = error(_("make_script: unhandled options"));
goto cleanup;
}
if (prepare_revision_walk(&revs) < 0)
return error(_("make_script: error preparing revisions"));
if (prepare_revision_walk(&revs) < 0) {
ret = error(_("make_script: error preparing revisions"));
goto cleanup;
}
if (rebase_merges)
return make_script_with_merges(&pp, &revs, out, flags);
if (rebase_merges) {
ret = make_script_with_merges(&pp, &revs, out, flags);
goto cleanup;
}
while ((commit = get_revision(&revs))) {
int is_empty = is_original_commit_empty(commit);
@ -5408,7 +5415,9 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
if (skipped_commit)
advise_if_enabled(ADVICE_SKIPPED_CHERRY_PICKS,
_("use --reapply-cherry-picks to include skipped commits"));
return 0;
cleanup:
release_revisions(&revs);
return ret;
}
/*