Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe2fbc5

Browse filesBrowse files
committed
Remote.fetch|pull() will not use poll/threads anymore as only stderr is read.
This simplification should improve performance and remove issues like those in gitpython-developers#232. NOTE: Debug code is still contained here
1 parent 3480201 commit fe2fbc5
Copy full SHA for fe2fbc5

2 files changed

+10-4Lines changed: 10 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/remote.py‎

Copy file name to clipboardExpand all lines: git/remote.py
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,10 @@ def _get_fetch_info_from_stderr(self, proc, progress):
525525
progress_handler = progress.new_message_handler()
526526

527527
stderr_fetch = open(join(self.repo.git_dir, '%03i_debug_git-python_stderr' % self.fetch_no), 'wb')
528-
def my_progress_handler(line):
529-
stderr_fetch.write((line + '\n').encode(defenc))
528+
for line in proc.stderr:
529+
line = line.decode(defenc)
530+
stderr_fetch.write((line).encode(defenc))
531+
line = line.rstrip()
530532
for pline in progress_handler(line):
531533
if line.startswith('fatal:'):
532534
raise GitCommandError(("Error when fetching: %s" % line,), 2)
@@ -541,12 +543,13 @@ def my_progress_handler(line):
541543
# end
542544

543545
# We are only interested in stderr here ...
544-
handle_process_output(proc, None, my_progress_handler, finalize_process)
546+
finalize_process(proc)
545547
stderr_fetch.close()
546548

547549
# read head information
548550
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))
551+
shutil.copyfile(join(self.repo.git_dir, 'FETCH_HEAD'),
552+
join(self.repo.git_dir, '%03i_debug_git-python_FETCH_HEAD' % self.fetch_no))
550553
self.fetch_no += 1
551554
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
552555
fetch_head_info = [l.decode(defenc) for l in fp.readlines()]
@@ -615,6 +618,7 @@ def fetch(self, refspec=None, progress=None, **kwargs):
615618
args = [refspec]
616619

617620
proc = self.repo.git.fetch(self, *args, with_extended_output=True, as_process=True, v=True, **kwargs)
621+
proc.stdout.close()
618622
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
619623
if hasattr(self.repo.odb, 'update_cache'):
620624
self.repo.odb.update_cache()
@@ -630,6 +634,7 @@ def pull(self, refspec=None, progress=None, **kwargs):
630634
:return: Please see 'fetch' method """
631635
kwargs = add_progress(kwargs, self.repo.git, progress)
632636
proc = self.repo.git.pull(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
637+
proc.stdout.close()
633638
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
634639
if hasattr(self.repo.odb, 'update_cache'):
635640
self.repo.odb.update_cache()
Collapse file

‎git/test/test_remote.py‎

Copy file name to clipboardExpand all lines: git/test/test_remote.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
348348
new_head = Head.create(rw_repo, "my_new_branch")
349349
progress = TestRemoteProgress()
350350
res = remote.push(new_head, progress)
351+
assert len(res) > 0
351352
assert res[0].flags & PushInfo.NEW_HEAD
352353
progress.make_assertion()
353354
self._do_test_push_result(res, remote)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.