Skip to content

Commit cd3f067

Browse files
committed
Merge branch 'bc/sequencer-export-work-tree-as-well'
"git rebase" started exporting GIT_DIR environment variable and exposing it to hook scripts when part of it got rewritten in C. Instead of matching the old scripted Porcelains' behaviour, compensate by also exporting GIT_WORK_TREE environment as well to lessen the damage. This can harm existing hooks that want to operate on different repository, but the current behaviour is already broken for them anyway. * bc/sequencer-export-work-tree-as-well: sequencer: pass absolute GIT_WORK_TREE to exec commands
2 parents c990330 + ab5e67d commit cd3f067

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

sequencer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,6 +2645,8 @@ static int do_exec(const char *command_line)
26452645
fprintf(stderr, "Executing: %s\n", command_line);
26462646
child_argv[0] = command_line;
26472647
argv_array_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
2648+
argv_array_pushf(&child_env, "GIT_WORK_TREE=%s",
2649+
absolute_path(get_git_work_tree()));
26482650
status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
26492651
child_env.argv);
26502652

t/t3404-rebase-interactive.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ test_expect_success 'rebase -i with exec allows git commands in subdirs' '
119119
)
120120
'
121121

122+
test_expect_success 'rebase -i sets work tree properly' '
123+
test_when_finished "rm -rf subdir" &&
124+
test_when_finished "test_might_fail git rebase --abort" &&
125+
mkdir subdir &&
126+
git rebase -x "(cd subdir && git rev-parse --show-toplevel)" HEAD^ \
127+
>actual &&
128+
! grep "/subdir$" actual
129+
'
130+
122131
test_expect_success 'rebase -i with the exec command checks tree cleanness' '
123132
git checkout master &&
124133
set_fake_editor &&

0 commit comments

Comments
 (0)