Last active
November 1, 2018 12:22
-
-
Save mathieucarbou/fd5c619816b5efc0d2a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- git.js 2015-05-11 16:19:29.114852900 -0400 | |
+++ git-patched.js 2015-05-11 16:19:35.788234600 -0400 | |
@@ -12,14 +12,23 @@ | |
, git = npm.config.get("git") | |
, assert = require("assert") | |
, log = require("npmlog") | |
+ , win32 = process.platform === "win32" | |
+ , cygwin = win32 && (process.env.ORIGINAL_PATH || '').indexOf('/cygdrive/') != -1 | |
function prefixGitArgs () { | |
- return process.platform === "win32" ? ["-c", "core.longpaths=true"] : [] | |
+ return win32 ? ["-c", "core.longpaths=true"] : [] | |
} | |
function execGit (args, options, cb) { | |
- log.info('git', args) | |
+ if(cygwin && args) { | |
+ for(var i=0; i<args.length; i++) { | |
+ if(':\\'.indexOf(args[i]) != 1) { | |
+ args[i] = args[i].replace(/\\/g, '/').replace(/^([A-Za-z])\:\//, '/cygdrive/$1/'); | |
+ } | |
+ } | |
+ } | |
var fullArgs = prefixGitArgs().concat(args || []) | |
+ log.info('git', fullArgs) | |
return exec(git, fullArgs, options, cb) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Didn't work for me for two reasons.
ORIGINAL_PATH
is not set (by /etc/profile) if a shell is a non-login shell (I'm running my commands via bash from a file manager called Far).There's
function spawnGit
ingit.js
which also needs the same paths treatment (not sure when npm uses which function).Here's my version of the patch that works on my system. I'm also checking if a system has both Cygwin's git and GfW git installed, which one is earlier in the
PATH
. Another note: I've replaced/cygdrive/
to/proc/cygdrive/
since on my system I've changed the default prefix to/mnt
(by adding a line to/etc/fstab
). Using Cygwin: