Skip to content

Commit 461434a

Browse files
phillipwoodgitster
authored andcommitted
rebase: stop reading and writing unnecessary strategy state
The state files for "--strategy" and "--strategy-option" are written and read twice, once by builtin/rebase.c and then by sequencer.c. This is an artifact of the scripted rebase and the need to support "rebase --preserve-merges". Now that "--preserve-merges" no-longer exists we only need to read and write these files in sequencer.c. This enables us to remove a call to free() in read_strategy_opts() that was added by f1f4ebf (sequencer.c: fix "opts->strategy" leak in read_strategy_opts(), 2022-11-08) as this commit fixes the root cause of that leak. There is further scope for removing duplication in the reading and writing of state files between builtin/rebase.c and sequencer.c but that is left for a follow up series. Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 140b947 commit 461434a

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

builtin/rebase.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -483,24 +483,6 @@ static int read_basic_state(struct rebase_options *opts)
483483
opts->gpg_sign_opt = xstrdup(buf.buf);
484484
}
485485

486-
if (file_exists(state_dir_path("strategy", opts))) {
487-
strbuf_reset(&buf);
488-
if (!read_oneliner(&buf, state_dir_path("strategy", opts),
489-
READ_ONELINER_WARN_MISSING))
490-
return -1;
491-
free(opts->strategy);
492-
opts->strategy = xstrdup(buf.buf);
493-
}
494-
495-
if (file_exists(state_dir_path("strategy_opts", opts))) {
496-
strbuf_reset(&buf);
497-
if (!read_oneliner(&buf, state_dir_path("strategy_opts", opts),
498-
READ_ONELINER_WARN_MISSING))
499-
return -1;
500-
free(opts->strategy_opts);
501-
opts->strategy_opts = xstrdup(buf.buf);
502-
}
503-
504486
strbuf_release(&buf);
505487

506488
return 0;
@@ -518,12 +500,6 @@ static int rebase_write_basic_state(struct rebase_options *opts)
518500
write_file(state_dir_path("quiet", opts), "%s", "");
519501
if (opts->flags & REBASE_VERBOSE)
520502
write_file(state_dir_path("verbose", opts), "%s", "");
521-
if (opts->strategy)
522-
write_file(state_dir_path("strategy", opts), "%s",
523-
opts->strategy);
524-
if (opts->strategy_opts)
525-
write_file(state_dir_path("strategy_opts", opts), "%s",
526-
opts->strategy_opts);
527503
if (opts->allow_rerere_autoupdate > 0)
528504
write_file(state_dir_path("allow_rerere_autoupdate", opts),
529505
"-%s-rerere-autoupdate",

sequencer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2944,7 +2944,6 @@ static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf)
29442944
strbuf_reset(buf);
29452945
if (!read_oneliner(buf, rebase_path_strategy(), 0))
29462946
return;
2947-
free(opts->strategy);
29482947
opts->strategy = strbuf_detach(buf, NULL);
29492948
if (!read_oneliner(buf, rebase_path_strategy_opts(), 0))
29502949
return;

0 commit comments

Comments
 (0)