diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2023-02-06 22:08:06 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-02-07 03:03:52 +0300 |
commit | 01fd5fb14b4f2a910679cf2ac672ff6b1d742f19 (patch) | |
tree | 4e54883d0a2f3c214930ffc493a9744c99fadda3 /builtin/rebase.c | |
parent | a6a323b31e2bcbac2518bddec71ea7ad558870eb (diff) |
rebase: use "cleanup" pattern in do_interactive_rebase()
Use a "goto cleanup" pattern in do_interactive_rebase(). This
eliminates some duplicated free() code added in 53bbcfbde7c (rebase
-i: implement the main part of interactive rebase as a builtin,
2018-09-27), and sets us up for a subsequent commit which'll make
further use of the "cleanup" label.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r-- | builtin/rebase.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c index 7171be40ee..c97ce642cf 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -254,7 +254,7 @@ static int init_basic_state(struct replay_opts *opts, const char *head_name, static int do_interactive_rebase(struct rebase_options *opts, unsigned flags) { - int ret; + int ret = -1; char *revisions = NULL, *shortrevisions = NULL; struct strvec make_script_args = STRVEC_INIT; struct todo_list todo_list = TODO_LIST_INIT; @@ -262,16 +262,12 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags) if (get_revision_ranges(opts->upstream, opts->onto, &opts->orig_head->object.oid, &revisions, &shortrevisions)) - return -1; + goto cleanup; if (init_basic_state(&replay, opts->head_name ? opts->head_name : "detached HEAD", - opts->onto, &opts->orig_head->object.oid)) { - free(revisions); - free(shortrevisions); - - return -1; - } + opts->onto, &opts->orig_head->object.oid)) + goto cleanup; if (!opts->upstream && opts->squash_onto) write_file(path_squash_onto(), "%s\n", @@ -300,6 +296,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags) opts->autosquash, opts->update_refs, &todo_list); } +cleanup: free(revisions); free(shortrevisions); todo_list_release(&todo_list); |