]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer.c: split up sequencer_remove_state()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 6 Feb 2023 19:08:07 +0000 (20:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Feb 2023 00:03:52 +0000 (16:03 -0800)
Split off the free()-ing in sequencer_remove_state() into a utility
function, which will be adjusted and called independent of the other
code in sequencer_remove_state() in a subsequent commit.

The only functional change here is changing the "int" to a "size_t",
which is the correct type, as "xopts_nr" is a "size_t".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c

index 3e4a197289714197b6ba391aa1bb26652eaaf836..b6392b43204f5a777177cc650687b48488ae6d43 100644 (file)
@@ -351,10 +351,22 @@ static const char *gpg_sign_opt_quoted(struct replay_opts *opts)
        return buf.buf;
 }
 
+static void replay_opts_release(struct replay_opts *opts)
+{
+       free(opts->gpg_sign);
+       free(opts->reflog_action);
+       free(opts->default_strategy);
+       free(opts->strategy);
+       for (size_t i = 0; i < opts->xopts_nr; i++)
+               free(opts->xopts[i]);
+       free(opts->xopts);
+       strbuf_release(&opts->current_fixups);
+}
+
 int sequencer_remove_state(struct replay_opts *opts)
 {
        struct strbuf buf = STRBUF_INIT;
-       int i, ret = 0;
+       int ret = 0;
 
        if (is_rebase_i(opts) &&
            strbuf_read_file(&buf, rebase_path_refs_to_delete(), 0) > 0) {
@@ -373,14 +385,7 @@ int sequencer_remove_state(struct replay_opts *opts)
                }
        }
 
-       free(opts->gpg_sign);
-       free(opts->reflog_action);
-       free(opts->default_strategy);
-       free(opts->strategy);
-       for (i = 0; i < opts->xopts_nr; i++)
-               free(opts->xopts[i]);
-       free(opts->xopts);
-       strbuf_release(&opts->current_fixups);
+       replay_opts_release(opts);
 
        strbuf_reset(&buf);
        strbuf_addstr(&buf, get_dir(opts));