From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: git@vger.kernel.org, Jacob Keller <jacob.keller@gmail.com>
Subject: Re: [PATCH] rebase: exec leaks GIT_DIR to environment
Date: Sat, 28 Oct 2017 18:00:35 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.21.1.1710281740070.6482@virtualbox> (raw)
In-Reply-To: <20171028000152.2760-1-jacob.e.keller@intel.com>
Hi Jake,
On Fri, 27 Oct 2017, Jacob Keller wrote:
> From: Jacob Keller <jacob.keller@gmail.com>
>
> I noticed a failure with git rebase interactive mode which causes "exec"
> commands to be run with GIT_DIR set. When GIT_DIR is in the environment,
> then any command which results in running a git command in
> a subdirectory will fail because GIT_DIR=".git".
>
> This unfortunately breaks one of my project's Makefiles, which uses
> git-describe to find the version information, but does so from within
> a sub directory.
>
> I'm in the process of running a bisect to find where this got
> introduced, but I suspect it's part of the rebase--helper changes that
> happened a while ago.
A safe assumption. I do not know how the shell code managed that GIT_DIR
reset, though:
-- snip from v2.12.0's git-rebase--interactive.sh --
x|"exec")
read -r command rest < "$todo"
mark_action_done
eval_gettextln "Executing: \$rest"
"${SHELL:-@SHELL_PATH@}" -c "$rest" # Actual execution
-- snap --
Maybe you can spot it?
The fix should be as easy as
-- snip --
diff --git a/sequencer.c b/sequencer.c
index f2c84c2fa62..018ba8d27e2 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1859,11 +1859,13 @@ static int error_failed_squash(struct commit *commit,
static int do_exec(const char *command_line)
{
const char *child_argv[] = { NULL, NULL };
+ const char *child_env[] = { "GIT_DIR", 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);
+ status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
+ child_env);
/* force re-reading of the cache */
if (discard_cache() < 0 || read_cache() < 0)
-- snap --
*However*, your test still fails with this, as
- your added test tries to remove the directory with -ff instead of -rf
- it tries to run `git rebase --abort` afterwards, which fails with my fix
because there is no rebase in progress
- instead of `cd subdir && ...`, it calls `>cd subdir && ...`, which
causes it to abort with a "subdir: not fonud"
So I need this, too, to make it all work:
-- snip --
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 60ab5136f70..967caab222a 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -108,13 +108,13 @@ test_expect_success 'rebase -i with the exec command runs from tree root' '
rm -fr subdir
'
-test_expect_failure 'rebase -i with the exec git commands in subdirs still work' '
- test_when_finished "rm -ff subdir" &&
- test_when_finished "git rebase --abort" &&
+test_expect_success 'rebase -i with the exec git commands in subdirs still work' '
+ 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" \
+ FAKE_LINES="1 exec_cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \
git rebase -i HEAD^
)
'
-- snap --
I only had time to write these two patches, and to verify that t3404
passes now, but not that anything else passes, neither to write a proper
commit message.
Maybe you can take it from there?
Ciao,
Dscho
next prev parent reply other threads:[~2017-10-28 16:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-28 0:01 [PATCH] rebase: exec leaks GIT_DIR to environment Jacob Keller
2017-10-28 16:00 ` Johannes Schindelin [this message]
2017-10-28 22:35 ` Jacob Keller
2017-10-29 18:34 ` Phillip Wood
2017-10-30 2:26 ` Junio C Hamano
2017-10-30 2:53 ` Jacob Keller
2017-10-30 3:36 ` Junio C Hamano
2017-10-30 6:26 ` Jacob Keller
2017-10-30 10:20 ` Phillip Wood
2017-10-30 12:46 ` Johannes Schindelin
2017-10-31 8:13 ` Jacob Keller
2017-10-30 2:51 ` Jacob Keller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.21.1.1710281740070.6482@virtualbox \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jacob.keller@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).