]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/revert.c: move free-ing of "revs" to replay_opts_release()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 6 Feb 2023 19:08:09 +0000 (20:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Feb 2023 00:03:52 +0000 (16:03 -0800)
In [1] and [2] I added the code being moved here to cmd_revert() and
cmd_cherry_pick(), now that we've got a "replay_opts_release()" for
the "struct replay_opts" it should know how to free these "revs",
rather than having these users reach into the struct to free its
individual members.

1. d1ec656d68f (cherry-pick: free "struct replay_opts" members,
   2022-11-08)
2. fd74ac95ac3 (revert: free "struct replay_opts" members, 2022-07-01)

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

index 1cab16bf3edc2a33fded1f5264920a3a3cb55928..77d2035616efa1aa60b412f024da1a7836df4478 100644 (file)
@@ -248,9 +248,6 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
        res = run_sequencer(argc, argv, &opts);
        if (res < 0)
                die(_("revert failed"));
-       if (opts.revs)
-               release_revisions(opts.revs);
-       free(opts.revs);
        replay_opts_release(&opts);
        return res;
 }
@@ -263,9 +260,6 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
        opts.action = REPLAY_PICK;
        sequencer_init_config(&opts);
        res = run_sequencer(argc, argv, &opts);
-       if (opts.revs)
-               release_revisions(opts.revs);
-       free(opts.revs);
        if (res < 0)
                die(_("cherry-pick failed"));
        replay_opts_release(&opts);
index 1547fb985979425d80e8d2331717cbdb7aff8015..cb4b1ce062cbe7a84edb5b4a587e6d9b3f97a5a0 100644 (file)
@@ -361,6 +361,9 @@ void replay_opts_release(struct replay_opts *opts)
                free(opts->xopts[i]);
        free(opts->xopts);
        strbuf_release(&opts->current_fixups);
+       if (opts->revs)
+               release_revisions(opts->revs);
+       free(opts->revs);
 }
 
 int sequencer_remove_state(struct replay_opts *opts)