summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-06-26 10:17:59 +0200
committerSebastian Thiel <byronimo@gmail.com>2015-06-26 10:22:36 +0200
commitdc81244873dce76db5694e6c1dbb6870c0f5dd02 (patch)
tree66a39fb662b30c99848af1e3fc005fc18602b962
parentcfc70fe92d42a853d4171943bde90d86061e3f3a (diff)
downloadgitpython-issue-301-reproduction.tar.gz
chore(remote): added debug helperissue-301-reproduction
Write debug files for stderr output as well as FETCH_INFO into the git repository, e.g. into `.git/` Help with #301
-rw-r--r--git/remote.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/git/remote.py b/git/remote.py
index c9da1979..dcab2c40 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -346,7 +346,7 @@ class Remote(LazyMixin, Iterable):
NOTE: When querying configuration, the configuration accessor will be cached
to speed up subsequent accesses."""
- __slots__ = ("repo", "name", "_config_reader")
+ __slots__ = ("repo", "name", "_config_reader", "fetch_no")
_id_attribute_ = "name"
def __init__(self, repo, name):
@@ -356,6 +356,7 @@ class Remote(LazyMixin, Iterable):
:param name: the name of the remote, i.e. 'origin'"""
self.repo = repo
self.name = name
+ self.fetch_no = 0
if os.name == 'nt':
# some oddity: on windows, python 2.5, it for some reason does not realize
@@ -551,6 +552,9 @@ class Remote(LazyMixin, Iterable):
progress_handler = progress.new_message_handler()
def my_progress_handler(line):
+ stderr_fetch = open(join(self.repo.git_dir, '%03i_debug_git-python_stderr' % self.fetch_no), 'ab')
+ stderr_fetch.write((line + '\n').encode(defenc))
+ stderr_fetch.close()
for pline in progress_handler(line):
if line.startswith('fatal:') or line.startswith('error:'):
raise GitCommandError(("Error when fetching: %s" % line,), 2)
@@ -567,6 +571,11 @@ class Remote(LazyMixin, Iterable):
# We are only interested in stderr here ...
handle_process_output(proc, None, my_progress_handler, finalize_process)
+ import shutil
+ shutil.copyfile(join(self.repo.git_dir, 'FETCH_HEAD'), join(self.repo.git_dir,
+ '%03i_debug_git-python_FETCH_HEAD' % self.fetch_no))
+ self.fetch_no += 1
+
# read head information
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
fetch_head_info = [l.decode(defenc) for l in fp.readlines()]