Skip to content

Commit b345b77

Browse files
committed
Merge branch 'en/rebase-i-microfixes'
* en/rebase-i-microfixes: git-rebase--merge: modernize "git-$cmd" to "git $cmd" Fix use of strategy options with interactive rebases t3418: add testcase showing problems with rebase -i and strategy options
2 parents 676c7e5 + d7f590b commit b345b77

4 files changed

+41
-4
lines changed

git-rebase--merge.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ call_merge () {
7171
test -z "$strategy" && strategy=recursive
7272
# If cmt doesn't have a parent, don't include it as a base
7373
base=$(git rev-parse --verify --quiet $cmt^)
74-
eval 'git-merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"'
74+
eval 'git merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"'
7575
rv=$?
7676
case "$rv" in
7777
0)
@@ -88,7 +88,7 @@ call_merge () {
8888
;;
8989
*)
9090
die "Unknown exit code ($rv) from command:" \
91-
"git-merge-$strategy $cmt^ -- HEAD $cmt"
91+
"git merge-$strategy $cmt^ -- HEAD $cmt"
9292
;;
9393
esac
9494
}

git-rebase.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ do
328328
do_merge=t
329329
;;
330330
--strategy-option=*)
331-
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--${1#--strategy-option=}")"
331+
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--${1#--strategy-option=}" | sed -e s/^.//)"
332332
do_merge=t
333333
test -z "$strategy" && strategy=recursive
334334
;;

sequencer.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,7 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
22072207
static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf)
22082208
{
22092209
int i;
2210+
char *strategy_opts_string;
22102211

22112212
strbuf_reset(buf);
22122213
if (!read_oneliner(buf, rebase_path_strategy(), 0))
@@ -2215,7 +2216,11 @@ static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf)
22152216
if (!read_oneliner(buf, rebase_path_strategy_opts(), 0))
22162217
return;
22172218

2218-
opts->xopts_nr = split_cmdline(buf->buf, (const char ***)&opts->xopts);
2219+
strategy_opts_string = buf->buf;
2220+
if (*strategy_opts_string == ' ')
2221+
strategy_opts_string++;
2222+
opts->xopts_nr = split_cmdline(strategy_opts_string,
2223+
(const char ***)&opts->xopts);
22192224
for (i = 0; i < opts->xopts_nr; i++) {
22202225
const char *arg = opts->xopts[i];
22212226

t/t3418-rebase-continue.sh

+32
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,38 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
7474
test -f funny.was.run
7575
'
7676

77+
test_expect_success 'rebase -i --continue handles merge strategy and options' '
78+
rm -fr .git/rebase-* &&
79+
git reset --hard commit-new-file-F2-on-topic-branch &&
80+
test_commit "commit-new-file-F3-on-topic-branch-for-dash-i" F3 32 &&
81+
test_when_finished "rm -fr test-bin funny.was.run funny.args" &&
82+
mkdir test-bin &&
83+
cat >test-bin/git-merge-funny <<-EOF &&
84+
#!$SHELL_PATH
85+
echo "\$@" >>funny.args
86+
case "\$1" in --opt) ;; *) exit 2 ;; esac
87+
case "\$2" in --foo) ;; *) exit 2 ;; esac
88+
case "\$4" in --) ;; *) exit 2 ;; esac
89+
shift 2 &&
90+
>funny.was.run &&
91+
exec git merge-recursive "\$@"
92+
EOF
93+
chmod +x test-bin/git-merge-funny &&
94+
(
95+
PATH=./test-bin:$PATH &&
96+
test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic
97+
) &&
98+
test -f funny.was.run &&
99+
rm funny.was.run &&
100+
echo "Resolved" >F2 &&
101+
git add F2 &&
102+
(
103+
PATH=./test-bin:$PATH &&
104+
git rebase --continue
105+
) &&
106+
test -f funny.was.run
107+
'
108+
77109
test_expect_success 'rebase passes merge strategy options correctly' '
78110
rm -fr .git/rebase-* &&
79111
git reset --hard commit-new-file-F3-on-topic-branch &&

0 commit comments

Comments
 (0)