Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-12-22 02:03:15 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-22 02:03:15 +0300
commit57f28f40943c077ef1dc11c693d693b1bd6b7f2f (patch)
tree635b6b07251371c7cac312e6596bac5a43940859
parent5a4069a1d86d98e3ba3f6aa748b5ad323983c420 (diff)
parent434e0636db102cd89292ea28e8e947fa6e790b23 (diff)
Merge branch 'en/rebase-x-wo-git-dir-env'
"git rebase -x" by mistake started exporting the GIT_DIR and GIT_WORK_TREE environment variables when the command was rewritten in C, which has been corrected. * en/rebase-x-wo-git-dir-env: sequencer: do not export GIT_DIR and GIT_WORK_TREE for 'exec'
-rw-r--r--sequencer.c9
-rwxr-xr-xt/t3409-rebase-environ.sh23
2 files changed, 24 insertions, 8 deletions
diff --git a/sequencer.c b/sequencer.c
index b69ef4dd4e..e314af4d60 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3497,17 +3497,12 @@ static int error_failed_squash(struct repository *r,
static int do_exec(struct repository *r, const char *command_line)
{
- struct strvec child_env = STRVEC_INIT;
const char *child_argv[] = { NULL, NULL };
int dirty, status;
fprintf(stderr, _("Executing: %s\n"), command_line);
child_argv[0] = command_line;
- strvec_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
- strvec_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.v);
+ status = run_command_v_opt(child_argv, RUN_USING_SHELL);
/* force re-reading of the cache */
if (discard_index(r->index) < 0 || repo_read_index(r) < 0)
@@ -3537,8 +3532,6 @@ static int do_exec(struct repository *r, const char *command_line)
status = 1;
}
- strvec_clear(&child_env);
-
return status;
}
diff --git a/t/t3409-rebase-environ.sh b/t/t3409-rebase-environ.sh
new file mode 100755
index 0000000000..83ffb39d9f
--- /dev/null
+++ b/t/t3409-rebase-environ.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+test_description='git rebase interactive environment'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_commit one &&
+ test_commit two &&
+ test_commit three
+'
+
+test_expect_success 'rebase --exec does not muck with GIT_DIR' '
+ git rebase --exec "printf %s \$GIT_DIR >environ" HEAD~1 &&
+ test_must_be_empty environ
+'
+
+test_expect_success 'rebase --exec does not muck with GIT_WORK_TREE' '
+ git rebase --exec "printf %s \$GIT_WORK_TREE >environ" HEAD~1 &&
+ test_must_be_empty environ
+'
+
+test_done