Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode characters in branch name #774

timqsh opened this issue Jun 19, 2018 · 1 comment

Unicode characters in branch name #774

timqsh opened this issue Jun 19, 2018 · 1 comment


Copy link

@timqsh timqsh commented Jun 19, 2018

Hi! I an trying to get diffs using GitPython, and i have an issue when branch name have unicode characters.

Here is repo where bug can be reproduced:

when i run this code:

repo = git.Repo('.')
HEAD = repo.head.commit

i get this error:

Traceback (most recent call last):
  File ".\", line 4, in <module>
    HEAD = repo.head.commit
  File "C:\Users\kushukov\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\refs\", line 200, in _get_commit
    obj = self._get_object()
  File "C:\Users\kushukov\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\refs\", line 193, in _get_object
    return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
  File "C:\Users\kushukov\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\refs\", line 135, in dereference_recursive
    hexsha, ref_path = cls._get_ref_info(repo, ref_path)
  File "C:\Users\kushukov\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\refs\", line 184, in _get_ref_info
    return cls._get_ref_info_helper(repo, ref_path)
  File "C:\Users\kushukov\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\refs\", line 167, in _get_ref_info_helper
    raise ValueError("Reference at %r does not exist" % ref_path)
ValueError: Reference at 'refs/heads/Р\u045aР\u0455С\u040fР\u2019Р\xb5С\u201aРєР°' does not exist

I am testing this on Windows 10.

forgot to add:
GitPython 2.1.10


This comment has been minimized.

Copy link

@Byron Byron commented Jul 15, 2018

Thanks for letting us know. It's a known issue that unicode usually breaks GitPython in various ways, it wasn't written with that in mind and back in the days, unicode wasn't something that one would become aware of during implementation.

Harmon758 added a commit to Harmon758/GitPython that referenced this issue Feb 18, 2020
@Harmon758 Harmon758 closed this in 863abe8 Feb 18, 2020
@Harmon758 Harmon758 removed the help wanted label Feb 18, 2020
@Byron Byron added this to the v3.0.9 - Bugfixes milestone Feb 19, 2020
wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this issue Mar 7, 2020

* Switched back to using gitdb package as requirement
  (`gitdb#59 <>`_)


* Restricted GitDB (gitdb2) version requirement to < 4
* Removed old nose library from test requirements


* Changed to use UTF-8 instead of default encoding when getting information about a symbolic reference
  (`#774 <>`_)
* Fixed decoding of tag object message so as to replace invalid bytes
  (`#943 <>`_)


* Added support for Python 3.8
* Bumped GitDB (gitdb2) version requirement to > 3


* Fixed Repo.__repr__ when subclassed
  (`#968 <>`_)
* Removed compatibility shims for Python < 3.4 and old mock library
* Replaced usage of deprecated unittest aliases and Logger.warn
* Removed old, no longer used assert methods
* Replaced usage of nose assert methods with unittest


Properly signed re-release of v3.0.6 with new signature
(See `#980 <>`_)


| Note: There was an issue that caused this version to be released to PyPI without a signature
| See the changelog for v3.0.7 and `#980 <>`_


* Fixed warning for usage of environment variables for paths containing ``$`` or ``%``
  (`#832 <>`_,
  `#961 <>`_)
* Added support for parsing Git internal date format (@<unix timestamp> <timezone offset>)
  (`#965 <>`_)
* Removed Python 2 and < 3.3 compatibility shims
  (`#979 <>`_)
* Fixed GitDB (gitdb2) requirement version specifier formatting in requirements.txt
  (`#979 <>`_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.