summaryrefslogtreecommitdiff
path: root/git/cmd.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2011-07-05 22:09:58 +0200
committerSebastian Thiel <byronimo@gmail.com>2011-07-05 22:09:58 +0200
commit7dcb07947cd71f47b5e2e5f101d289e263506ca9 (patch)
tree0919e03e08db0edd1e1698a0249c3e15241f6e7a /git/cmd.py
parent1ddf05a78475a194ed1aa082d26b3d27ecc77475 (diff)
downloadgitpython-7dcb07947cd71f47b5e2e5f101d289e263506ca9.tar.gz
Implemented GIT_PYTHON_GIT_EXECUTABLE including test and docs
Diffstat (limited to 'git/cmd.py')
-rw-r--r--git/cmd.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/git/cmd.py b/git/cmd.py
index b3ca0f48..63a7134e 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -17,9 +17,6 @@ from subprocess import (
PIPE
)
-# Enables debugging of GitPython's git commands
-GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False)
-
execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output',
'with_exceptions', 'as_process',
'output_stream' )
@@ -29,6 +26,7 @@ __all__ = ('Git', )
def dashify(string):
return string.replace('_', '-')
+
class Git(LazyMixin):
"""
The Git class manages communication with the Git binary.
@@ -50,6 +48,13 @@ class Git(LazyMixin):
# The size in bytes read from stdout when copying git's output to another stream
max_chunk_size = 1024*64
+ # Enables debugging of GitPython's git commands
+ GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False)
+
+ # Provide the full path to the git executable. Otherwise it assumes git is in the path
+ GIT_PYTHON_GIT_EXECUTABLE = os.environ.get("GIT_PYTHON_GIT_EXECUTABLE", 'git')
+
+
class AutoInterrupt(object):
"""Kill/Interrupt the stored process instance once this instance goes out of scope. It is
used to prevent processes piling up in case iterators stop reading.
@@ -311,7 +316,7 @@ class Git(LazyMixin):
:note:
If you add additional keyword arguments to the signature of this method,
you must update the execute_kwargs tuple housed in this module."""
- if GIT_PYTHON_TRACE and not GIT_PYTHON_TRACE == 'full':
+ if self.GIT_PYTHON_TRACE and not self.GIT_PYTHON_TRACE == 'full':
print ' '.join(command)
# Allow the user to have the command executed in their working dir.
@@ -358,7 +363,7 @@ class Git(LazyMixin):
proc.stdout.close()
proc.stderr.close()
- if GIT_PYTHON_TRACE == 'full':
+ if self.GIT_PYTHON_TRACE == 'full':
cmdstr = " ".join(command)
if stderr_value:
print "%s -> %d; stdout: '%s'; stderr: '%s'" % (cmdstr, status, stdout_value, stderr_value)
@@ -445,7 +450,7 @@ class Git(LazyMixin):
ext_args = self.__unpack_args([a for a in args if a is not None])
args = opt_args + ext_args
- call = ["git", dashify(method)]
+ call = [self.GIT_PYTHON_GIT_EXECUTABLE, dashify(method)]
call.extend(args)
return self.execute(call, **_kwargs)