summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorAndreas Gutsche <andreas.h.gutsche@gmail.com>2011-01-06 15:21:09 +0100
committerAndreas Gutsche <andreas.h.gutsche@gmail.com>2011-01-06 15:21:09 +0100
commitb424f87a276e509dcaaee6beb10ca00c12bb7d29 (patch)
tree21eff20f9f86bb785837026f5ae46b2ad44e26ca /git
parent46f63c30e30364eb04160df71056d4d34e97af21 (diff)
downloadgitpython-b424f87a276e509dcaaee6beb10ca00c12bb7d29.tar.gz
Added the bugfix code as a utility function to be reused wherever this specific subprocess bug occurs.
Diffstat (limited to 'git')
-rw-r--r--git/cmd.py8
-rw-r--r--git/diff.py3
-rw-r--r--git/util.py10
3 files changed, 14 insertions, 7 deletions
diff --git a/git/cmd.py b/git/cmd.py
index d1600b74..af8417b7 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -4,7 +4,7 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-import os, sys, platform, time
+import os, sys
from util import *
from exc import GitCommandError
@@ -87,11 +87,7 @@ class Git(object):
"""Wait for the process and return its status code.
:raise GitCommandError: if the return status is not 0"""
-
- #HACK: These two lines are necessary because OSX raises an error if you try to .wait() right after creating the process object.
- # It is only necessary when using GUI frameworks to instantiate an application.
- if platform.system().startswith("Darwin") and "pyside" in sys.modules.keys() or "PySide" in sys.modules.keys():
- time.sleep(0.1)
+ sleep_on_gui_present_osx_crashfix()
status = self.proc.wait()
if status != 0:
raise GitCommandError(self.args, status, self.proc.stderr.read())
diff --git a/git/diff.py b/git/diff.py
index 48253c42..c2597bd9 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -10,6 +10,8 @@ from objects.util import mode_str_to_int
from exc import GitCommandError
from gitdb.util import hex_to_bin
+
+from util import sleep_on_gui_present_osx_crashfix
__all__ = ('Diffable', 'DiffIndex', 'Diff')
@@ -99,6 +101,7 @@ class Diffable(object):
diff_method = Diff._index_from_patch_format
index = diff_method(self.repo, proc.stdout)
+ sleep_on_gui_present_osx_crashfix()
status = proc.wait()
return index
diff --git a/git/util.py b/git/util.py
index 8c0b6697..f81e3741 100644
--- a/git/util.py
+++ b/git/util.py
@@ -21,7 +21,7 @@ from gitdb.util import (
)
__all__ = ( "stream_copy", "join_path", "to_native_path_windows", "to_native_path_linux",
- "join_path_native", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList",
+ "join_path_native", "sleep_on_gui_present_osx_crashfix", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList",
"BlockingLockFile", "LockFile", 'Actor', 'get_user_id', 'assure_directory_exists',
'RemoteProgress')
@@ -101,6 +101,14 @@ def get_user_id():
# END get username from login
return "%s@%s" % (username, platform.node())
+def sleep_on_gui_present_osx_crashfix():
+ """This fixes a crash which appears when using pyside on OS X."""
+
+ #HACK: These two lines are necessary because OSX raises an error if you try to .wait() right after creating the process object.
+ # It is only necessary when using GUI frameworks to instantiate an application.
+ if platform.system().startswith("Darwin") and "PySide" in sys.modules.keys():
+ time.sleep(0.1)
+
#} END utilities
#{ Classes