builtin/revert.c: move free-ing of "revs" to replay_opts_release()
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>
Ævar Arnfjörð Bjarmason committed
Feb 6, 2023 at 20:08 UTC
a6a700a43c6f73f5abef95f97355ff8ce0523e0e
2 files changed
+3
-6
builtin/revert.c
-6
@@ -248,9 +248,6 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
248
res = run_sequencer(argc, argv, &opts);
249
if (res < 0)
250
die(_("revert failed"));
251
- if (opts.revs)
252
- release_revisions(opts.revs);
253
- free(opts.revs);
251
replay_opts_release(&opts);
252
return res;
253
}
@@ -263,9 +260,6 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
260
opts.action = REPLAY_PICK;
261
sequencer_init_config(&opts);
262
res = run_sequencer(argc, argv, &opts);
266
- if (opts.revs)
267
- release_revisions(opts.revs);
268
- free(opts.revs);
263
if (res < 0)
264
die(_("cherry-pick failed"));
265
replay_opts_release(&opts);
sequencer.c
+3
@@ -361,6 +361,9 @@ void replay_opts_release(struct replay_opts *opts)
361
free(opts->xopts[i]);
362
free(opts->xopts);
363
strbuf_release(&opts->current_fixups);
364
+ if (opts->revs)
365
+ release_revisions(opts->revs);
366
+ free(opts->revs);
367
}
368
369
int sequencer_remove_state(struct replay_opts *opts)