git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Brandon Williams <bmwill@google.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: What's cooking in git.git (Nov 2016, #06; Mon, 28)
Date: Wed, 30 Nov 2016 18:59:52 -0500	[thread overview]
Message-ID: <20161130235952.4j63gkdlbobjitdb@sigill.intra.peff.net> (raw)
In-Reply-To: <20161130234636.6az7xfywzprpn6ly@sigill.intra.peff.net>

On Wed, Nov 30, 2016 at 06:46:36PM -0500, Jeff King wrote:

> > For now the work around could be to just pass "-C <dir>" to the child
> > process instead of relying on run-command to chdir.
> 
> Yeah, that would push it after the exec. I just don't understand why
> that would be necessary.

Hmm. It still seems to fail, even with the workaround (the patch in
run-command is there to make sure there's not some other call that we're
not catching):

diff --git a/builtin/grep.c b/builtin/grep.c
index 2c727ef49..3323a3e7f 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -553,6 +553,7 @@ static int grep_submodule_launch(struct grep_opt *opt,
 	argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
 			 super_prefix ? super_prefix : "",
 			 name);
+	argv_array_pushl(&cp.args, "-C", gs->path, NULL);
 	argv_array_push(&cp.args, "grep");
 
 	/*
@@ -586,7 +587,6 @@ static int grep_submodule_launch(struct grep_opt *opt,
 	}
 
 	cp.git_cmd = 1;
-	cp.dir = gs->path;
 
 	/*
 	 * Capture output to output buffer and check the return code from the
diff --git a/run-command.c b/run-command.c
index 5a4dbb66d..d040f4f77 100644
--- a/run-command.c
+++ b/run-command.c
@@ -393,6 +393,8 @@ int start_command(struct child_process *cmd)
 			close(cmd->out);
 		}
 
+		if (cmd->dir && git_env_bool("GIT_NO_CHDIR", 0))
+			die("temporarily disallowing chdir");
 		if (cmd->dir && chdir(cmd->dir))
 			die_errno("exec '%s': cd to '%s' failed", cmd->argv[0],
 			    cmd->dir);
diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh
index 050777186..591ff74ed 100755
--- a/t/t7814-grep-recurse-submodules.sh
+++ b/t/t7814-grep-recurse-submodules.sh
@@ -175,7 +175,7 @@ test_expect_success 'grep recurse submodule colon in name' '
 	fi:le:foobar
 	su:b/fi:le:foobar
 	EOF
-	git -C parent grep -e "foobar" --recurse-submodules >actual &&
+	GIT_NO_CHDIR=1 strace -o foo.out -f git -C parent grep -e "foobar" --recurse-submodules >actual &&
 	test_cmp expect actual &&
 
 	cat >expect <<-\EOF &&


So I think there is some other chdir(). I'm not sure if there is an easy
way to get a backtrace on every call to chdir() in every thread. I'm
sure somebody more clever than me could figure out how to make gdb do it
automatically, but it might be workable manually. I think the chdir was
in the main thread.

-Peff

  parent reply	other threads:[~2016-11-30 23:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29  0:15 What's cooking in git.git (Nov 2016, #06; Mon, 28) Junio C Hamano
2016-11-29  1:05 ` Brandon Williams
2016-11-29  6:37   ` Jeff King
2016-11-29  6:51     ` Jeff King
2016-11-30 19:54       ` Brandon Williams
2016-11-30 23:28         ` Brandon Williams
2016-11-30 23:32           ` Jeff King
2016-11-30 23:40             ` Jeff King
2016-11-30 23:42               ` Brandon Williams
2016-11-30 23:46                 ` Jeff King
2016-11-30 23:57                   ` Brandon Williams
2016-11-30 23:59                   ` Jeff King [this message]
2016-12-01  0:04                     ` Jeff King
2016-12-01  0:08                       ` Brandon Williams
2016-12-01  0:14                         ` Stefan Beller
2016-12-01  1:14                           ` Brandon Williams
2016-12-01  0:06                     ` Brandon Williams
2016-12-01  0:19                       ` Jeff King
2016-11-30 23:43               ` Stefan Beller
2016-12-01  7:09               ` Johannes Sixt
2016-12-01  7:19                 ` Jeff King
2016-11-29  6:59 ` Jeff King
2016-11-29 18:31   ` Junio C Hamano
2016-11-29 18:37     ` Jeff King
2016-11-29 19:21 ` Stefan Beller
2016-11-29 19:26   ` Junio C Hamano
2016-11-29 19:29     ` Stefan Beller
2016-11-30  0:25   ` Stefan Beller
2016-12-01  8:30 ` bw/transport-protocol-policy Jeff King
2016-12-01 18:14   ` bw/transport-protocol-policy Brandon Williams
2016-12-01 19:20     ` bw/transport-protocol-policy Jeff King
2016-12-01 19:35       ` bw/transport-protocol-policy Brandon Williams
2016-12-01 19:46         ` bw/transport-protocol-policy Jeff King
2016-12-01 19:53           ` bw/transport-protocol-policy Brandon Williams

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=20161130235952.4j63gkdlbobjitdb@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).