From: Jeff King <peff@peff.net>
To: Lars Schneider <larsxschneider@gmail.com>
Cc: Jacob Keller <jacob.keller@gmail.com>,
Stefan Beller <sbeller@google.com>,
Git Users <git@vger.kernel.org>,
Jens.Lehmann@web.de
Subject: Re: [RFC] How to pass Git config command line instructions to Submodule commands?
Date: Thu, 28 Apr 2016 08:05:04 -0400 [thread overview]
Message-ID: <20160428120504.GA22399@sigill.intra.peff.net> (raw)
In-Reply-To: <20160428112511.GA11522@sigill.intra.peff.net>
On Thu, Apr 28, 2016 at 07:25:11AM -0400, Jeff King wrote:
> > diff --git a/git-submodule.sh b/git-submodule.sh
> > index 2a84d7e..b02f5b9 100755
> > --- a/git-submodule.sh
> > +++ b/git-submodule.sh
> > @@ -199,7 +199,7 @@ sanitize_submodule_env()
> > {
> > sanitized_config=$(git submodule--helper sanitize-config)
> > clear_local_git_env
> > - GIT_CONFIG_PARAMETERS=$sanitized_config
> > + export GIT_CONFIG_PARAMETERS=$sanitized_config
> > }
>
> If you already have $GIT_CONFIG_PARAMETERS exported when we enter the
> function, then we should not need to re-export it when changing the
> value in the final line (the export bit is retained by the shell). But
> if you don't have it set already, then $sanitized_config must by
> definition be empty.
>
> So it should do the right thing without the export.
>
> At the same time, clear_local_git_env() will call "unset" on
> GIT_CONFIG_PARAMETERS. Which would clear the export bit, meaning the
> final line doesn't ever have any impact on sub-programs, and the whole
> thing is totally broken. But then, why does the test in t5550 pass?
>
> Confused...
Ah. t5550 passes because it does not exercise this code path at all. We
try a recursive clone, which calls "git submodule update --init", which
does not seem to clear the config at all. So it works even without
14111fc49.
I tried to improve the test by adding git-fetch (note that I also fixed
a bug where we use $HTTP_URL instead of $HTTPD_URL, and added some
whitespace to make the result more readable):
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 69ef388..6ec3ba3 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -103,12 +103,23 @@ test_expect_success 'cmdline credential config passes into submodules' '
git submodule add "$HTTPD_URL/auth/dumb/repo.git" sub &&
git commit -m "add submodule"
) &&
+
set_askpass wrong pass@host &&
test_must_fail git clone --recursive super super-clone &&
rm -rf super-clone &&
+
set_askpass wrong pass@host &&
- git -c "credential.$HTTP_URL.username=user@host" \
+ git -c "credential.$HTTPD_URL.username=user@host" \
clone --recursive super super-clone &&
+ expect_askpass pass user@host &&
+
+ set_askpass wrong pass@host &&
+ test_must_fail git -C super-clone fetch --recurse-submodules &&
+
+ set_askpass wrong pass@host &&
+ git -C super-clone \
+ -c "credential.$HTTPD_URL.username=user@host" \
+ fetch --recurse-submodules &&
expect_askpass pass user@host
'
but that doesn't pass, even with the export fix! That's because fetch
doesn't go through git-submodule at all; it calls "git fetch" itself,
and uses local_repo_env, which clears the config. It needs to learn to
use the same mechanism that sanitize_submodule_env() does.
So AFAICT 14111fc49 is totally broken. It doesn't actually work for
git-submodule (because of the missing export), nor for git-fetch
(because that skips the shell script), and the one case we are testing
already worked without it (but probably _should_ be sanitizing the
config, so is buggy, too).
-Peff
next prev parent reply other threads:[~2016-04-28 12:05 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-25 10:39 [RFC] How to pass Git config command line instructions to Submodule commands? Lars Schneider
2016-04-25 17:02 ` Stefan Beller
2016-04-25 20:59 ` Jacob Keller
2016-04-25 21:24 ` Jeff King
2016-04-25 21:27 ` Jeff King
2016-04-28 11:06 ` Lars Schneider
2016-04-28 11:25 ` Jeff King
2016-04-28 12:05 ` Jeff King [this message]
2016-04-28 12:17 ` Jeff King
2016-04-28 13:35 ` [PATCH 0/5] fixes for sanitized submodule config Jeff King
2016-04-28 13:36 ` [PATCH 1/5] t5550: fix typo in $HTTPD_URL Jeff King
2016-04-28 15:24 ` Jacob Keller
2016-04-28 15:25 ` Jeff King
2016-04-28 15:26 ` Jacob Keller
2016-04-28 13:37 ` [PATCH 2/5] t5550: break submodule config test into multiple sub-tests Jeff King
2016-04-28 15:21 ` Stefan Beller
2016-04-28 15:25 ` Jeff King
2016-04-28 15:25 ` Jacob Keller
2016-04-28 13:37 ` [PATCH 3/5] submodule: export sanitized GIT_CONFIG_PARAMETERS Jeff King
2016-04-28 15:25 ` Stefan Beller
2016-04-28 15:28 ` Jeff King
2016-04-28 15:35 ` Stefan Beller
2016-04-28 16:51 ` Johannes Schindelin
2016-04-28 15:28 ` Jacob Keller
2016-04-28 15:36 ` Jeff King
2016-04-28 15:40 ` Jacob Keller
2016-04-28 13:38 ` [PATCH 4/5] submodule--helper: move config-sanitizing to submodule.c Jeff King
2016-04-28 15:30 ` Stefan Beller
2016-04-28 15:37 ` Jeff King
2016-04-28 16:28 ` Lars Schneider
2016-04-28 13:39 ` [PATCH 5/5] submodule: use prepare_submodule_repo_env consistently Jeff King
2016-04-28 14:02 ` [PATCH 0/5] fixes for sanitized submodule config Johannes Schindelin
2016-04-28 15:56 ` Stefan Beller
2016-04-28 16:03 ` Jacob Keller
2016-04-28 12:05 ` [RFC] How to pass Git config command line instructions to Submodule commands? Lars Schneider
2016-04-28 13:40 ` Jeff King
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=20160428120504.GA22399@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=jacob.keller@gmail.com \
--cc=larsxschneider@gmail.com \
--cc=sbeller@google.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).