Git fork

Merge branch 'en/keep-cwd' into maint

Fix a regression in 2.35 that roke the use of "rebase" and "stash"
in a secondary worktree.

* en/keep-cwd:
sequencer, stash: fix running from worktree subdir

+30 -2
+5 -1
builtin/stash.c
··· 1539 1539 struct child_process cp = CHILD_PROCESS_INIT; 1540 1540 1541 1541 cp.git_cmd = 1; 1542 - if (startup_info->original_cwd) 1542 + if (startup_info->original_cwd) { 1543 1543 cp.dir = startup_info->original_cwd; 1544 + strvec_pushf(&cp.env_array, "%s=%s", 1545 + GIT_WORK_TREE_ENVIRONMENT, 1546 + the_repository->worktree); 1547 + } 1544 1548 strvec_pushl(&cp.args, "clean", "--force", 1545 1549 "--quiet", "-d", ":/", NULL); 1546 1550 if (include_untracked == INCLUDE_ALL_FILES)
+4 -1
sequencer.c
··· 4223 4223 4224 4224 cmd.git_cmd = 1; 4225 4225 4226 - if (startup_info->original_cwd) 4226 + if (startup_info->original_cwd) { 4227 4227 cmd.dir = startup_info->original_cwd; 4228 + strvec_pushf(&cmd.env_array, "%s=%s", 4229 + GIT_WORK_TREE_ENVIRONMENT, r->worktree); 4230 + } 4228 4231 strvec_push(&cmd.args, "checkout"); 4229 4232 strvec_push(&cmd.args, commit); 4230 4233 strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
+21
t/t3400-rebase.sh
··· 416 416 mv actual_logs .git/logs 417 417 ' 418 418 419 + test_expect_success 'rebase when inside worktree subdirectory' ' 420 + git init main-wt && 421 + ( 422 + cd main-wt && 423 + git commit --allow-empty -m "initial" && 424 + mkdir -p foo/bar && 425 + test_commit foo/bar/baz && 426 + mkdir -p a/b && 427 + test_commit a/b/c && 428 + # create another branch for our other worktree 429 + git branch other && 430 + git worktree add ../other-wt other && 431 + cd ../other-wt && 432 + # create and cd into a subdirectory 433 + mkdir -p random/dir && 434 + cd random/dir && 435 + # now do the rebase 436 + git rebase --onto HEAD^^ HEAD^ # drops the HEAD^ commit 437 + ) 438 + ' 439 + 419 440 test_done