Skip to content

Commit 57f28f4

Browse files
committed
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'
2 parents 5a4069a + 434e063 commit 57f28f4

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

sequencer.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,17 +3497,12 @@ static int error_failed_squash(struct repository *r,
34973497

34983498
static int do_exec(struct repository *r, const char *command_line)
34993499
{
3500-
struct strvec child_env = STRVEC_INIT;
35013500
const char *child_argv[] = { NULL, NULL };
35023501
int dirty, status;
35033502

35043503
fprintf(stderr, _("Executing: %s\n"), command_line);
35053504
child_argv[0] = command_line;
3506-
strvec_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
3507-
strvec_pushf(&child_env, "GIT_WORK_TREE=%s",
3508-
absolute_path(get_git_work_tree()));
3509-
status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
3510-
child_env.v);
3505+
status = run_command_v_opt(child_argv, RUN_USING_SHELL);
35113506

35123507
/* force re-reading of the cache */
35133508
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)
35373532
status = 1;
35383533
}
35393534

3540-
strvec_clear(&child_env);
3541-
35423535
return status;
35433536
}
35443537

t/t3409-rebase-environ.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
test_description='git rebase interactive environment'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success 'setup' '
8+
test_commit one &&
9+
test_commit two &&
10+
test_commit three
11+
'
12+
13+
test_expect_success 'rebase --exec does not muck with GIT_DIR' '
14+
git rebase --exec "printf %s \$GIT_DIR >environ" HEAD~1 &&
15+
test_must_be_empty environ
16+
'
17+
18+
test_expect_success 'rebase --exec does not muck with GIT_WORK_TREE' '
19+
git rebase --exec "printf %s \$GIT_WORK_TREE >environ" HEAD~1 &&
20+
test_must_be_empty environ
21+
'
22+
23+
test_done

0 commit comments

Comments
 (0)