Skip to content

Commit 0060041

Browse files
newrengitster
authored andcommitted
Fix use of strategy options with interactive rebases
git-rebase.sh wrote strategy options to .git/rebase/merge/strategy_opts in the following format: '--ours' '--renormalize' Note the double spaces. git-rebase--interactive uses sequencer.c to parse that file, and sequencer.c used split_cmdline() to get the individual strategy options. After splitting, sequencer.c prefixed each "option" with a double dash, so, concatenating all its options would result in: -- --ours -- --renormalize So, when it ended up calling try_merge_strategy(), that in turn would run git merge-$strategy -- --ours -- --renormalize $merge_base -- $head $remote instead of the expected/desired git merge-$strategy --ours --renormalize $merge_base -- $head $remote Remove the extra spaces so that when it goes through split_cmdline() we end up with the desired command line. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5a959d commit 0060041

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

git-rebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ do
289289
do_merge=t
290290
;;
291291
--strategy-option=*)
292-
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--${1#--strategy-option=}")"
292+
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--${1#--strategy-option=}" | sed -e s/^.//)"
293293
do_merge=t
294294
test -z "$strategy" && strategy=recursive
295295
;;

sequencer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,7 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
20002000
static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf)
20012001
{
20022002
int i;
2003+
char *strategy_opts_string;
20032004

20042005
strbuf_reset(buf);
20052006
if (!read_oneliner(buf, rebase_path_strategy(), 0))
@@ -2008,7 +2009,11 @@ static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf)
20082009
if (!read_oneliner(buf, rebase_path_strategy_opts(), 0))
20092010
return;
20102011

2011-
opts->xopts_nr = split_cmdline(buf->buf, (const char ***)&opts->xopts);
2012+
strategy_opts_string = buf->buf;
2013+
if (*strategy_opts_string == ' ')
2014+
strategy_opts_string++;
2015+
opts->xopts_nr = split_cmdline(strategy_opts_string,
2016+
(const char ***)&opts->xopts);
20122017
for (i = 0; i < opts->xopts_nr; i++) {
20132018
const char *arg = opts->xopts[i];
20142019

t/t3418-rebase-continue.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
7474
test -f funny.was.run
7575
'
7676

77-
test_expect_failure 'rebase -i --continue handles merge strategy and options' '
77+
test_expect_success 'rebase -i --continue handles merge strategy and options' '
7878
rm -fr .git/rebase-* &&
7979
git reset --hard commit-new-file-F2-on-topic-branch &&
8080
test_commit "commit-new-file-F3-on-topic-branch-for-dash-i" F3 32 &&

0 commit comments

Comments
 (0)