From 2ac9c19695468e16f7d9a86722b449cbaf38052d Mon Sep 17 00:00:00 2001 From: Ivan Bryzzhin Date: Mon, 15 Jul 2019 17:28:42 +0300 Subject: [PATCH 1/2] fix encoding problems on windows with not using default encoding but utf-8 --- git/remote.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/git/remote.py b/git/remote.py index 0965c1f60..0bab3be90 100644 --- a/git/remote.py +++ b/git/remote.py @@ -786,8 +786,7 @@ def fetch(self, refspec=None, progress=None, **kwargs): else: args = [refspec] - proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False, - universal_newlines=True, v=True, **kwargs) + proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False, v=True, **kwargs) res = self._get_fetch_info_from_stderr(proc, progress) if hasattr(self.repo.odb, 'update_cache'): self.repo.odb.update_cache() @@ -805,8 +804,7 @@ def pull(self, refspec=None, progress=None, **kwargs): # No argument refspec, then ensure the repo's config has a fetch refspec. self._assert_refspec() kwargs = add_progress(kwargs, self.repo.git, progress) - proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True, - universal_newlines=True, v=True, **kwargs) + proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True, v=True, **kwargs) res = self._get_fetch_info_from_stderr(proc, progress) if hasattr(self.repo.odb, 'update_cache'): self.repo.odb.update_cache() @@ -840,8 +838,7 @@ def push(self, refspec=None, progress=None, **kwargs): If the operation fails completely, the length of the returned IterableList will be null.""" kwargs = add_progress(kwargs, self.repo.git, progress) - proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, - universal_newlines=True, **kwargs) + proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, **kwargs) return self._get_push_info(proc, progress) @property From 74cb7af385c3d32ed789293548cf9203b4713f94 Mon Sep 17 00:00:00 2001 From: Ivan Bryzzhin Date: Mon, 15 Jul 2019 18:16:56 +0300 Subject: [PATCH 2/2] by default file opens in default locale, it throw exception with unicode branch names with calling repo.branch --- git/refs/symbolic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index a8ca6538f..638048fb6 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -90,7 +90,7 @@ def _iter_packed_refs(cls, repo): """Returns an iterator yielding pairs of sha1/path pairs (as bytes) for the corresponding refs. :note: The packed refs file will be kept open as long as we iterate""" try: - with open(cls._get_packed_refs_path(repo), 'rt') as fp: + with open(cls._get_packed_refs_path(repo), 'rt', encoding='utf-8') as fp: for line in fp: line = line.strip() if not line: