From: Elijah Newren Date: Thu, 9 Dec 2021 05:08:31 +0000 (+0000) Subject: rebase: do not attempt to remove startup_info->original_cwd X-Git-Tag: v2.35.0-rc0~41^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc3ae46b420f58dfe2bfd87714dca096a043d554;p=thirdparty%2Fgit.git 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 Acked-by: Ævar Arnfjörð Bjarmason Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- diff --git a/sequencer.c b/sequencer.c index ea96837cde..83f257e7fa 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4228,6 +4228,8 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts, cmd.git_cmd = 1; + if (startup_info->original_cwd) + cmd.dir = startup_info->original_cwd; strvec_push(&cmd.args, "checkout"); strvec_push(&cmd.args, commit); strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action); diff --git a/t/t2501-cwd-empty.sh b/t/t2501-cwd-empty.sh index b1182390ba..52335a8afe 100755 --- a/t/t2501-cwd-empty.sh +++ b/t/t2501-cwd-empty.sh @@ -166,11 +166,11 @@ test_expect_success 'cherry-pick fails if cwd needs to be removed' ' ' test_expect_success 'rebase does not clean cwd incidentally' ' - test_incidental_dir_removal failure git rebase reverted + test_incidental_dir_removal success git rebase reverted ' test_expect_success 'rebase fails if cwd needs to be removed' ' - test_required_dir_removal failure git rebase fd_conflict + test_required_dir_removal success git rebase fd_conflict ' test_expect_success 'revert does not clean cwd incidentally' '