Skip to content

Commit df7abff

Browse files
committed
sequencer (rebase -i): respect strategy/strategy_opts settings
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent c1fb559 commit df7abff

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

sequencer.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ static GIT_PATH_FUNC(head_name, "rebase-merge/head-name")
108108
static GIT_PATH_FUNC(onto, "rebase-merge/onto")
109109
static GIT_PATH_FUNC(orig_head, "rebase-merge/orig-head")
110110
static GIT_PATH_FUNC(git_path_rebase_verbose, "rebase-merge/verbose") /* TODO: turn into opt */
111+
static GIT_PATH_FUNC(git_path_strategy, "rebase-merge/strategy")
112+
static GIT_PATH_FUNC(git_path_strategy_opts, "rebase-merge/strategy_opts")
111113

112114
#define IS_REBASE_I() (opts->action == REPLAY_INTERACTIVE_REBASE)
113115

@@ -1273,6 +1275,28 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
12731275

12741276
static int read_populate_opts(struct replay_opts *opts)
12751277
{
1278+
if (IS_REBASE_I()) {
1279+
struct strbuf buf = STRBUF_INIT;
1280+
if (file_exists(git_path_strategy())) {
1281+
if (strbuf_read_file(&buf, git_path_strategy(),
1282+
0) > 0) {
1283+
strbuf_rtrim(&buf);
1284+
opts->strategy = strbuf_detach(&buf, NULL);
1285+
}
1286+
if (strbuf_read_file(&buf, git_path_strategy_opts(),
1287+
0) > 0) {
1288+
strbuf_trim(&buf);
1289+
opts->xopts_nr = split_cmdline(buf.buf,
1290+
&opts->xopts);
1291+
{ int i; for (i = 0; i < opts->xopts_nr; i++) skip_prefix(opts->xopts[i], "--", &opts->xopts[i]); }
1292+
if (opts->xopts_nr)
1293+
strbuf_detach(&buf, NULL);
1294+
else
1295+
strbuf_release(&buf);
1296+
}
1297+
}
1298+
return 0;
1299+
}
12761300
if (!file_exists(git_path_opts_file()))
12771301
return 0;
12781302
if (git_config_from_file(populate_opts_cb, git_path_opts_file(), opts) < 0)

0 commit comments

Comments
 (0)