Skip to content

Commit

Permalink
Fix npm#2597 Don't set GIT_* envs in child processes
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 13, 2012
1 parent 53ab10b commit af8c981
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/cache.js
Expand Up @@ -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) {
Expand All @@ -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 = {}
Expand Down

0 comments on commit af8c981

Please sign in to comment.