diff options
author | Florian Apolloner <florian@apolloner.eu> | 2008-05-20 23:26:06 +0200 |
---|---|---|
committer | Florian Apolloner <florian@apolloner.eu> | 2008-05-20 23:26:06 +0200 |
commit | ae54e18d7ca7bc8b8fbc667119fb60b25f0f3871 (patch) | |
tree | 6ae9d3978476b54653f426bd971d07e46f8d368b /lib/git_python/git.py | |
parent | 9b975d9fcf5924800f9ea5d68d7d79f743ca9af7 (diff) | |
download | gitpython-ae54e18d7ca7bc8b8fbc667119fb60b25f0f3871.tar.gz |
made subprocess not use a shell...
Diffstat (limited to 'lib/git_python/git.py')
-rw-r--r-- | lib/git_python/git.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/git_python/git.py b/lib/git_python/git.py index 2251ecb2..25cd1cce 100644 --- a/lib/git_python/git.py +++ b/lib/git_python/git.py @@ -12,8 +12,6 @@ class Git(MethodMissingMixin): super(Git, self).__init__() self.git_dir = git_dir - git_binary = "/usr/bin/env git" - @property def get_dir(self): return self.git_dir @@ -26,12 +24,14 @@ class Git(MethodMissingMixin): ``command`` The command to execute """ - print command + print ' '.join(command) proc = subprocess.Popen(command, - shell=True, + cwd = self.git_dir, stdout=subprocess.PIPE ) - stdout_value = proc.communicate()[0] + proc.wait() + stdout_value = proc.stdout.read() + proc.stdout.close() return stdout_value def transform_kwargs(self, **kwargs): @@ -44,12 +44,13 @@ class Git(MethodMissingMixin): if v is True: args.append("-%s" % k) else: - args.append("-%s %r" % (k, v)) + args.append("-%s" % k) + args.append(v) else: if v is True: args.append("--%s" % dashify(k)) else: - args.append("--%s=%r" % (dashify(k), v)) + args.append("--%s=%s" % (dashify(k), v)) return args def method_missing(self, method, *args, **kwargs): @@ -73,9 +74,10 @@ class Git(MethodMissingMixin): str """ opt_args = self.transform_kwargs(**kwargs) - ext_args = map(lambda a: (a == '--') and a or "%s" % shell_escape(a), args) + ext_args = map(lambda a: (a == '--') and a or "%s" % a, args) args = opt_args + ext_args - call = "%s --git-dir=%s %s %s" % (self.git_binary, self.git_dir, dashify(method), ' '.join(args)) + call = ['git-'+dashify(method)] + call.extend(args) stdout_value = self.execute(call) return stdout_value |