Permalink
Browse files

Fix #2597 Don't set GIT_* envs in child processes

  • Loading branch information...
isaacs committed Jul 13, 2012
1 parent 53ab10b commit af8c981c04f869f2a48644dc61f6a2e7b3395fae
Showing with 16 additions and 2 deletions.
  1. +16 −2 lib/cache.js
View
@@ -386,15 +386,15 @@ function addRemoteGit (u, parsed, name, cb_) {
var tmp = path.join(npm.tmp, Date.now()+"-"+Math.random())
mkdir(path.dirname(tmp), function (er) {
if (er) return cb(er)
- exec( npm.config.get("git"), ["clone", u, tmp], null, false
+ exec( npm.config.get("git"), ["clone", u, tmp], gitEnv(), false
, function (er, code, stdout, stderr) {
stdout = (stdout + "\n" + stderr).trim()
if (er) {
log.error("git clone " + u, stdout)
return cb(er)
}
log.verbose("git clone "+u, stdout)
- exec( npm.config.get("git"), ["checkout", co], null, false, tmp
+ exec( npm.config.get("git"), ["checkout", co], gitEnv(), false, tmp
, function (er, code, stdout, stderr) {
stdout = (stdout + "\n" + stderr).trim()
if (er) {
@@ -410,6 +410,20 @@ function addRemoteGit (u, parsed, name, cb_) {
}
+var gitEnv_
+function gitEnv () {
+ // git responds to env vars in some weird ways in post-receive hooks
+ // so don't carry those along.
+ if (gitEnv_) return gitEnv_
+ gitEnv_ = {}
+ for (var k in process.env) {
+ if (k.match(/^GIT/)) continue
+ gitEnv_[k] = process.env[k]
+ }
+ return gitEnv_
+}
+
+
// only have one request in flight for a given
// name@blah thing.
var inFlightNames = {}

1 comment on commit af8c981

@grenade

This comment has been minimized.

Show comment Hide comment
@grenade

grenade Jun 20, 2014

This change introduces other issues: #5257
The result is that git (git://) protocol urls cannot be fetched on systems without support for that protocol.

This change introduces other issues: #5257
The result is that git (git://) protocol urls cannot be fetched on systems without support for that protocol.

Please sign in to comment.