summaryrefslogtreecommitdiff
path: root/lib/git_python
diff options
context:
space:
mode:
authorMichael Trier <mtrier@gmail.com>2008-05-26 10:51:07 -0400
committerMichael Trier <mtrier@gmail.com>2008-05-26 10:51:07 -0400
commit27ceafbb3f74b4677d5bae6c7ea031de07c6cfad (patch)
tree1a5cf74ebc29d6b3ddc6c686133a56389cad88d2 /lib/git_python
parent7c60b88138b836307bdde0487c4ffb82121b1c5e (diff)
parent70094734d601e1220c95ac586fdffbda3a23e10b (diff)
downloadgitpython-27ceafbb3f74b4677d5bae6c7ea031de07c6cfad.tar.gz
Merge git://gitorious.org/git-python/apollo13
Diffstat (limited to 'lib/git_python')
-rw-r--r--lib/git_python/__init__.py2
-rw-r--r--lib/git_python/git.py43
-rw-r--r--lib/git_python/utils.py3
3 files changed, 24 insertions, 24 deletions
diff --git a/lib/git_python/__init__.py b/lib/git_python/__init__.py
index 71142a40..11f93313 100644
--- a/lib/git_python/__init__.py
+++ b/lib/git_python/__init__.py
@@ -11,7 +11,7 @@ from git_python.repo import Repo
from git_python.stats import Stats
from git_python.tag import Tag
from git_python.tree import Tree
-from git_python.utils import shell_escape, dashify, touch
+from git_python.utils import dashify, touch
__all__ = [ name for name, obj in locals().items()
if not (name.startswith('_') or inspect.ismodule(obj)) ]
diff --git a/lib/git_python/git.py b/lib/git_python/git.py
index ee256356..aad1f85d 100644
--- a/lib/git_python/git.py
+++ b/lib/git_python/git.py
@@ -11,27 +11,27 @@ class Git(MethodMissingMixin):
def __init__(self, git_dir):
super(Git, self).__init__()
self.git_dir = git_dir
-
- git_binary = "/usr/bin/env git"
-
+
@property
def get_dir(self):
return self.git_dir
-
+
def execute(self, command):
"""
Handles executing the command on the shell and consumes and returns
the returned information (stdout)
-
+
``command``
The command to execute
"""
- print command
- proc = subprocess.Popen(command,
- shell=True,
- stdout=subprocess.PIPE
+ print ' '.join(command)
+ proc = subprocess.Popen(command,
+ 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,38 +44,41 @@ 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):
"""
Run the given git command with the specified arguments and return
the result as a String
-
+
``method``
is the command
-
+
``args``
is the list of arguments
-
+
``kwargs``
is a dict of keyword arguments
Examples
git.rev_list('master', max_count=10, header=True)
-
+
Returns
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
diff --git a/lib/git_python/utils.py b/lib/git_python/utils.py
index 2bd6f2cd..c2140ba0 100644
--- a/lib/git_python/utils.py
+++ b/lib/git_python/utils.py
@@ -1,6 +1,3 @@
-def shell_escape(string):
- return str(string).replace("'", "\\\\'")
-
def dashify(string):
return string.replace('_', '-')