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
This commit is contained in:
commit
cd3f067815
@ -2645,6 +2645,8 @@ static int do_exec(const char *command_line)
|
||||
fprintf(stderr, "Executing: %s\n", command_line);
|
||||
child_argv[0] = command_line;
|
||||
argv_array_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
|
||||
argv_array_pushf(&child_env, "GIT_WORK_TREE=%s",
|
||||
absolute_path(get_git_work_tree()));
|
||||
status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
|
||||
child_env.argv);
|
||||
|
||||
|
@ -119,6 +119,15 @@ test_expect_success 'rebase -i with exec allows git commands in subdirs' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'rebase -i sets work tree properly' '
|
||||
test_when_finished "rm -rf subdir" &&
|
||||
test_when_finished "test_might_fail git rebase --abort" &&
|
||||
mkdir subdir &&
|
||||
git rebase -x "(cd subdir && git rev-parse --show-toplevel)" HEAD^ \
|
||||
>actual &&
|
||||
! grep "/subdir$" actual
|
||||
'
|
||||
|
||||
test_expect_success 'rebase -i with the exec command checks tree cleanness' '
|
||||
git checkout master &&
|
||||
set_fake_editor &&
|
||||
|
Loading…
Reference in New Issue
Block a user