diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-11-15 12:04:56 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-15 12:04:56 +0900 |
commit | adfc49e60bb1ae4e1239d8fd5d35127de160058b (patch) | |
tree | 6126472166194d4bbd1c687d37ad2324fb501471 | |
parent | Merge branch 'bw/grep-recurse-submodules' into maint (diff) | |
parent | sequencer: pass absolute GIT_DIR to exec commands (diff) | |
download | tgif-adfc49e60bb1ae4e1239d8fd5d35127de160058b.tar.xz |
Merge branch 'jk/rebase-i-exec-gitdir-fix' into maint
A recent regression in "git rebase -i" that broke execution of git
commands from subdirectories via "exec" insn has been fixed.
* jk/rebase-i-exec-gitdir-fix:
sequencer: pass absolute GIT_DIR to exec commands
-rw-r--r-- | sequencer.c | 7 | ||||
-rwxr-xr-x | t/t3404-rebase-interactive.sh | 11 |
2 files changed, 17 insertions, 1 deletions
diff --git a/sequencer.c b/sequencer.c index f2a10cc4f2..332a383b03 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1862,12 +1862,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) @@ -1897,6 +1900,8 @@ static int do_exec(const char *command_line) status = 1; } + argv_array_clear(&child_env); + return status; } diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 3704dbb2ec..6a82d1ed87 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -108,6 +108,17 @@ test_expect_success 'rebase -i with the exec command runs from tree root' ' rm -fr subdir ' +test_expect_success 'rebase -i with exec allows git commands in subdirs' ' + test_when_finished "rm -rf subdir" && + test_when_finished "git rebase --abort ||:" && + git checkout master && + mkdir subdir && (cd subdir && + set_fake_editor && + FAKE_LINES="1 exec_cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \ + git rebase -i HEAD^ + ) +' + test_expect_success 'rebase -i with the exec command checks tree cleanness' ' git checkout master && set_fake_editor && |