Skip to content

Commit 93122c9

Browse files
newrengitster
authored andcommitted
rebase: fix handling of restrict_revision
restrict_revision in the original shell script was an excluded revision range. It is also treated that way by the am-backend. In the conversion from shell to C (see commit 6ab54d1 ("rebase -i: implement the logic to initialize $revisions in C", 2018-08-28)), the interactive-backend accidentally treated it as a positive revision rather than a negated one. This was missed as there were no tests in the testsuite that tested an interactive rebase with fork-point behavior. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 55d2b6d commit 93122c9

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

builtin/rebase.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
348348

349349
argv_array_pushl(&make_script_args, "", revisions, NULL);
350350
if (opts->restrict_revision)
351-
argv_array_push(&make_script_args,
352-
oid_to_hex(&opts->restrict_revision->object.oid));
351+
argv_array_pushf(&make_script_args, "^%s",
352+
oid_to_hex(&opts->restrict_revision->object.oid));
353353

354354
ret = sequencer_make_script(the_repository, &todo_list.buf,
355355
make_script_args.argc, make_script_args.argv,

t/t3400-rebase.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,29 @@ test_expect_success 'rebase works with format.useAutoBase' '
165165
git rebase master
166166
'
167167

168-
test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' '
168+
test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--merge)' '
169169
git checkout -b default-base master &&
170170
git checkout -b default topic &&
171171
git config branch.default.remote . &&
172172
git config branch.default.merge refs/heads/default-base &&
173+
git rebase --merge &&
174+
git rev-parse --verify default-base >expect &&
175+
git rev-parse default~1 >actual &&
176+
test_cmp expect actual &&
177+
git checkout default-base &&
178+
git reset --hard HEAD^ &&
179+
git checkout default &&
180+
git rebase --merge &&
181+
git rev-parse --verify default-base >expect &&
182+
git rev-parse default~1 >actual &&
183+
test_cmp expect actual
184+
'
185+
186+
test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' '
187+
git checkout -B default-base master &&
188+
git checkout -B default topic &&
189+
git config branch.default.remote . &&
190+
git config branch.default.merge refs/heads/default-base &&
173191
git rebase &&
174192
git rev-parse --verify default-base >expect &&
175193
git rev-parse default~1 >actual &&

0 commit comments

Comments
 (0)