Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3480201

Browse files
committed
Added debug code to keep lines fed into progress handler and the contents of FETCH_HEAD.
This data will be written into the git-repository itself, prefixed with the number of the operation. Thus, a test-run with exactly one fetch operation would look like this afterwards: ls -l .git total 96 -----> -rw-r--r-- 1 byron staff 141B Jan 16 11:54 000_debug_git-python_FETCH_HEAD <----- -----> -rw-r--r-- 1 byron staff 180B Jan 16 11:54 000_debug_git-python_stderr <----- -rw-r--r-- 1 byron staff 487B Jan 16 11:54 FETCH_HEAD -rw-r--r-- 1 byron staff 22B Jan 16 11:54 HEAD -rw-r--r-- 1 byron staff 41B Jan 16 11:54 ORIG_HEAD drwxr-xr-x 2 byron staff 68B Jan 16 11:54 branches/ -rw-r--r-- 1 byron staff 560B Jan 16 11:54 config -rw-r--r-- 1 byron staff 73B Jan 16 11:54 description drwxr-xr-x 11 byron staff 374B Jan 16 11:54 hooks/ -rw-r--r-- 1 byron staff 13K Jan 16 11:54 index drwxr-xr-x 3 byron staff 102B Jan 16 11:54 info/ drwxr-xr-x 4 byron staff 136B Jan 16 11:54 logs/ drwxr-xr-x 12 byron staff 408B Jan 16 11:54 objects/ -rw-r--r-- 1 byron staff 1.2K Jan 16 11:54 packed-refs drwxr-xr-x 5 byron staff 170B Jan 16 11:54 refs/ [ci skip]
1 parent a9a5414 commit 3480201

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

git/remote.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class Remote(LazyMixin, Iterable):
338338
NOTE: When querying configuration, the configuration accessor will be cached
339339
to speed up subsequent accesses."""
340340

341-
__slots__ = ("repo", "name", "_config_reader")
341+
__slots__ = ("repo", "name", "_config_reader", "fetch_no")
342342
_id_attribute_ = "name"
343343

344344
def __init__(self, repo, name):
@@ -348,6 +348,7 @@ def __init__(self, repo, name):
348348
:param name: the name of the remote, i.e. 'origin'"""
349349
self.repo = repo
350350
self.name = name
351+
self.fetch_no = 0
351352

352353
if os.name == 'nt':
353354
# some oddity: on windows, python 2.5, it for some reason does not realize
@@ -523,7 +524,9 @@ def _get_fetch_info_from_stderr(self, proc, progress):
523524

524525
progress_handler = progress.new_message_handler()
525526

527+
stderr_fetch = open(join(self.repo.git_dir, '%03i_debug_git-python_stderr' % self.fetch_no), 'wb')
526528
def my_progress_handler(line):
529+
stderr_fetch.write((line + '\n').encode(defenc))
527530
for pline in progress_handler(line):
528531
if line.startswith('fatal:'):
529532
raise GitCommandError(("Error when fetching: %s" % line,), 2)
@@ -539,8 +542,12 @@ def my_progress_handler(line):
539542

540543
# We are only interested in stderr here ...
541544
handle_process_output(proc, None, my_progress_handler, finalize_process)
545+
stderr_fetch.close()
542546

543547
# read head information
548+
import shutil
549+
shutil.copyfile(join(self.repo.git_dir, 'FETCH_HEAD'), join(self.repo.git_dir, '%03i_debug_git-python_FETCH_HEAD' % self.fetch_no))
550+
self.fetch_no += 1
544551
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
545552
fetch_head_info = [l.decode(defenc) for l in fp.readlines()]
546553
fp.close()

0 commit comments

Comments
 (0)