@matheusbsbs / matheus-bagliano / commits / 93122c985a
Fork 0

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 6ab54d17be3f ("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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Feb 15, 2020 at 21:36 UTC 93122c985a3671bd4e15b3dbc6b457c981eb8c23
2 files changed +21 -3
builtin/rebase.c
+2 -2
@@ -348,8 +348,8 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
348
349 argv_array_pushl(&make_script_args, "", revisions, NULL);
350 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));
353
354 ret = sequencer_make_script(the_repository, &todo_list.buf,
355 make_script_args.argc, make_script_args.argv,
t/t3400-rebase.sh
+19 -1
@@ -165,11 +165,29 @@ test_expect_success 'rebase works with format.useAutoBase' '
165 git rebase master
166 '
167
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)' '
169 git checkout -b default-base master &&
170 git checkout -b default topic &&
171 git config branch.default.remote . &&
172 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 &&
191 git rebase &&
192 git rev-parse --verify default-base >expect &&
193 git rev-parse default~1 >actual &&