Skip to content

Commit bc3ae46

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Acked-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c65744e commit bc3ae46

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

sequencer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4228,6 +4228,8 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
42284228

42294229
cmd.git_cmd = 1;
42304230

4231+
if (startup_info->original_cwd)
4232+
cmd.dir = startup_info->original_cwd;
42314233
strvec_push(&cmd.args, "checkout");
42324234
strvec_push(&cmd.args, commit);
42334235
strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);

t/t2501-cwd-empty.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ test_expect_success 'cherry-pick fails if cwd needs to be removed' '
166166
'
167167

168168
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
170170
'
171171

172172
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
174174
'
175175

176176
test_expect_success 'revert does not clean cwd incidentally' '

0 commit comments

Comments
 (0)