diff options
author | Jacob Keller <jacob.keller@gmail.com> | 2017-10-31 16:07:33 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-02 10:53:23 +0900 |
commit | 09d7b6c6fab3ad131b71016b61c80d39d532befd (patch) | |
tree | 8a9acdf7d1ac012b88200c4b9c5a490de46d8cde /sequencer.c | |
parent | 098ed50e8a7c581e23cd51b737fb780228fe6f31 (diff) | |
download | git-09d7b6c6fab3ad131b71016b61c80d39d532befd.tar.gz |
sequencer: pass absolute GIT_DIR to exec commandsjk/rebase-i-exec-gitdir-fix
When we replaced the old shell script based interactive rebase in
commmit 18633e1a22a6 ("rebase -i: use the rebase--helper builtin",
2017-02-09) we introduced a regression of functionality in that the
GIT_DIR would be sent to the environment of the exec command as-is.
This generally meant that it would be passed as "GIT_DIR=.git", which
causes problems for any exec command that wants to run git commands in
a subdirectory.
This isn't a very large regression, since it is not that likely that the
exec command will run a git command, and even less likely that it will
need to do so in a subdir. This regression was discovered by a build
system which uses git-describe to find the current version of the build
system, and happened to do so from the src/ sub directory of the
project.
Fix this by passing in the absolute path of the git directory into the
child environment.
Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sequencer.c b/sequencer.c index 1f729b053b..689d9a3117 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1821,12 +1821,15 @@ static int error_failed_squash(struct commit *commit, static int do_exec(const char *command_line) { + struct argv_array child_env = ARGV_ARRAY_INIT; const char *child_argv[] = { NULL, NULL }; int dirty, status; fprintf(stderr, "Executing: %s\n", command_line); child_argv[0] = command_line; - status = run_command_v_opt(child_argv, RUN_USING_SHELL); + argv_array_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir())); + status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL, + child_env.argv); /* force re-reading of the cache */ if (discard_cache() < 0 || read_cache() < 0) @@ -1856,6 +1859,8 @@ static int do_exec(const char *command_line) status = 1; } + argv_array_clear(&child_env); + return status; } |