try to use win32api.FindExecutable('git') for .bat and .cmd support instead of runnin...
authorStefan Zimmermann <zimmermann.code@gmail.com>
Thu, 7 May 2015 06:52:29 +0000 (08:52 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 7 May 2015 11:01:25 +0000 (11:01 +0000)
dulwich/client.py

index 7131d57d0e3b98d34e510259e3ff5656732de3b8..b99c52a1bba0e262bd2181e1cc10dffac1985a3f 100644 (file)
@@ -663,7 +663,14 @@ class SubprocessGitClient(TraditionalGitClient):
 
     git = ['git']
     if sys.platform == 'win32': # support .exe, .bat and .cmd
-        git = ['cmd', '/c'] + git
+        try: # to avoid overhead
+            import win32api
+        except ImportError: # run through cmd.exe with some overhead
+            git = ['cmd', '/c'] + git
+        else:
+            status, git = win32api.FindExecutable('git')
+            #TODO: need to check status? (exc is raised if not found)
+            git = [git]
 
     def _connect(self, service, path):
         import subprocess