From ab5e67d7513ac6efb4c0ee9787aeaa41604c0566 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sat, 14 Jul 2018 18:38:59 +0000 Subject: sequencer: pass absolute GIT_WORK_TREE to exec commands The sequencer currently passes GIT_DIR, but not GIT_WORK_TREE, to exec commands. In that configuration, we assume that whatever directory we're in is the top level of the work tree, and git rev-parse --show-toplevel responds accordingly. However, when we're in a subdirectory, that isn't correct: we respond with the subdirectory as the top level, resulting in unexpected behavior. Ensure that we pass GIT_WORK_TREE as well as GIT_DIR so that git operations within subdirectories work correctly. Note that we are guaranteed to have a work tree in this case: the relevant sequencer functions are called only from revert, cherry-pick, and rebase--helper; all of these commands require a working tree. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- sequencer.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index 4d3f60594c..dda854779d 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1883,6 +1883,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); -- cgit v1.3