Skip to content

Instantly share code, notes, and snippets.

@amb26
Forked from mathieucarbou/git.diff
Created November 25, 2015 17:34
Show Gist options
  • Save amb26/e4bc4a7e8054fea73d43 to your computer and use it in GitHub Desktop.
Save amb26/e4bc4a7e8054fea73d43 to your computer and use it in GitHub Desktop.
--- 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