summaryrefslogtreecommitdiff
path: root/deps/npm/lib/utils/git.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/utils/git.js')
-rw-r--r--deps/npm/lib/utils/git.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/deps/npm/lib/utils/git.js b/deps/npm/lib/utils/git.js
index 6770853dd9..1951640e81 100644
--- a/deps/npm/lib/utils/git.js
+++ b/deps/npm/lib/utils/git.js
@@ -28,6 +28,16 @@ function execGit (args, options, cb) {
function spawnGit (args, options) {
log.info('git', args)
+ // If we're already in a git command (eg, running test as an exec
+ // line in an interactive rebase) then these environment variables
+ // will force git to operate on the current project, instead of
+ // checking out/fetching/etc. whatever the user actually intends.
+ options.env = options.env || Object.keys(process.env)
+ .filter(k => !/^GIT/.test(k))
+ .reduce((set, k) => {
+ set[k] = process.env[k]
+ return set
+ }, {})
return spawn(git, prefixGitArgs().concat(args || []), options)
}