Skip to content

Commit a6a700a

Browse files
avargitster
authored andcommitted
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. d1ec656 (cherry-pick: free "struct replay_opts" members, 2022-11-08) 2. fd74ac9 (revert: free "struct replay_opts" members, 2022-07-01) Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9ff2f06 commit a6a700a

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

builtin/revert.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,6 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
248248
res = run_sequencer(argc, argv, &opts);
249249
if (res < 0)
250250
die(_("revert failed"));
251-
if (opts.revs)
252-
release_revisions(opts.revs);
253-
free(opts.revs);
254251
replay_opts_release(&opts);
255252
return res;
256253
}
@@ -263,9 +260,6 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
263260
opts.action = REPLAY_PICK;
264261
sequencer_init_config(&opts);
265262
res = run_sequencer(argc, argv, &opts);
266-
if (opts.revs)
267-
release_revisions(opts.revs);
268-
free(opts.revs);
269263
if (res < 0)
270264
die(_("cherry-pick failed"));
271265
replay_opts_release(&opts);

sequencer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ void replay_opts_release(struct replay_opts *opts)
361361
free(opts->xopts[i]);
362362
free(opts->xopts);
363363
strbuf_release(&opts->current_fixups);
364+
if (opts->revs)
365+
release_revisions(opts->revs);
366+
free(opts->revs);
364367
}
365368

366369
int sequencer_remove_state(struct replay_opts *opts)

0 commit comments

Comments
 (0)