rebase: do not attempt to remove startup_info->original_cwd
Since rebase spawns a `checkout` subprocess, make sure we run that from the startup_info->original_cwd directory, so that the checkout process knows to protect that directory. Acked-by: Derrick Stolee <stolee@gmail.com> Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Dec 9, 2021 at 05:08 UTC
bc3ae46b420f58dfe2bfd87714dca096a043d554
2 files changed
+4
-2
sequencer.c
+2
@@ -4228,6 +4228,8 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
4228
4229
cmd.git_cmd = 1;
4230
4231
+ if (startup_info->original_cwd)
4232
+ cmd.dir = startup_info->original_cwd;
4233
strvec_push(&cmd.args, "checkout");
4234
strvec_push(&cmd.args, commit);
4235
strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
t/t2501-cwd-empty.sh
+2
-2
@@ -166,11 +166,11 @@ test_expect_success 'cherry-pick fails if cwd needs to be removed' '
166
'
167
168
test_expect_success 'rebase does not clean cwd incidentally' '
169
- test_incidental_dir_removal failure git rebase reverted
169
+ test_incidental_dir_removal success git rebase reverted
170
'
171
172
test_expect_success 'rebase fails if cwd needs to be removed' '
173
- test_required_dir_removal failure git rebase fd_conflict
173
+ test_required_dir_removal success git rebase fd_conflict
174
'
175
176
test_expect_success 'revert does not clean cwd incidentally' '