]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase: do not attempt to remove startup_info->original_cwd
authorElijah Newren <newren@gmail.com>
Thu, 9 Dec 2021 05:08:31 +0000 (05:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Dec 2021 21:33:13 +0000 (13:33 -0800)
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>
sequencer.c
t/t2501-cwd-empty.sh

index ea96837cde3bad6faa9cf016323fe3267a538cb4..83f257e7fa4187cabf86bb4c3304f952b16e0c61 100644 (file)
@@ -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);
index b1182390ba388dcac48afef716eab002bdc8188a..52335a8afe9cee06f50cb6d5c58a978fe076dc5d 100755 (executable)
@@ -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' '